We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5eb6272 commit 619a5a1Copy full SHA for 619a5a1
solution/0342.Power of Four/README.md
@@ -0,0 +1,17 @@
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?
solution/0342.Power of Four/Solution.js
@@ -0,0 +1,3 @@
+const isPowerOfFour = function(num) {
+ return (Math.log(num) / Math.log(4)) % 1.0 == 0.0;
+};
solution/README.md
@@ -876,6 +876,8 @@
876
│ └── Solution.cpp
877
├── 0331.Verify Preorder Serialization of a Binary Tree
878
│ └── Solution.java
879
+├── 0342.Power of Four
880
+│ └── Solution.js
881
├── 0343.Integer Break
882
│ ├── README.md
883
│ ├── README_EN.md
0 commit comments