Skip to content

Commit fb5d0e7

Browse files
authored
Create Power-of-Four.cpp
1 parent 3e547eb commit fb5d0e7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

LeetCode/Power-of-Four.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public:
3+
bool isPowerOfFour(int n) {
4+
if (n <= 0) return false;
5+
while (n % 4 == 0) {
6+
n /= 4;
7+
}
8+
return n == 1;
9+
}
10+
};

0 commit comments

Comments
 (0)