Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
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)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /