File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ # 342. Power of Four
2
+
3
+ Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
4
+
5
+ ## Example 1:
6
+ ```
7
+ Input: 16
8
+ Output: true
9
+ ```
10
+
11
+ ## Example 2:
12
+ ```
13
+ Input: 5
14
+ Output: false
15
+ ```
16
+
17
+ Follow up: Could you solve it without loops/recursion?
Original file line number Diff line number Diff line change
1
+ const isPowerOfFour = function ( num ) {
2
+ return ( Math . log ( num ) / Math . log ( 4 ) ) % 1.0 == 0.0 ;
3
+ } ;
Original file line number Diff line number Diff line change 876
876
βΒ Β βββ Solution.cpp
877
877
βββ 0331.Verify Preorder Serialization of a Binary Tree
878
878
βΒ Β βββ Solution.java
879
+ βββ 0342.Power of Four
880
+ βΒ Β βββ Solution.js
879
881
βββ 0343.Integer Break
880
882
βΒ Β βββ README.md
881
883
βΒ Β βββ README_EN.md
You canβt perform that action at this time.
0 commit comments