Mark As Completed Discussion

Good morning! Here's our prompt for today.

Given an integer num, write a method to determine if it is a power of 3.

Description

The method will be called as follows:

JAVASCRIPT
1console.log(powerOfThree(9));
2// true
3
4console.log(powerOfThree(7));
5// false

Constraints

  • The given would be a non zero positive integer in the range between 1 and 2147483647
  • Expected space complexity : O(logn)
  • Expected time complexity : O(1)

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's a video of us explaining the solution.

To change the speed of the video or see it in full screen, click the icons to the right of the progress bar.

Here's our guided, illustrated walk-through.

How do I use this guide?