Skip to content

Commit 0fb3858

Browse files
authored
Merge pull request doocs#247 from Gapur/master
Power of four
2 parents f60c574 + 619a5a1 commit 0fb3858

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 17 additions & 0 deletions
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?
Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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)