Skip to content

Commit 619a5a1

Browse files
committed
implement power of four
1 parent 5eb6272 commit 619a5a1

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

solution/0342.Power of Four/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -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?
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const isPowerOfFour = function(num) {
2+
return (Math.log(num) / Math.log(4)) % 1.0 == 0.0;
3+
};

solution/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,8 @@
876876
│   └── Solution.cpp
877877
├── 0331.Verify Preorder Serialization of a Binary Tree
878878
│   └── Solution.java
879+
├── 0342.Power of Four
880+
│   └── Solution.js
879881
├── 0343.Integer Break
880882
│   ├── README.md
881883
│   ├── README_EN.md

0 commit comments

Comments
 (0)