public boolean isPowerOfTwo(int n) {
if(n<1)
return false;
while(n!=1){
if(n%2!=0)
return false;
n>>=1;
}
return true;
}
相关文章
- 09-19[LeetCode] 231 Power of Two && 326 Power of Three && 342 Power of Four
- 09-19Leetcode 231 Power of Two 数论
- 09-19[LeetCode] 231. Power of Two ☆(是否2 的幂)
- 09-19LN : leetcode 231 Power of Two
- 09-19LeetCode 231 Power of Two
- 09-19LeetCode算法题-Intersection of Two Linked Lists(Java实现)
- 09-19【JAVA、C++】LeetCode 004 Median of Two Sorted Arrays
- 09-19【JAVA、C++】LeetCode 002 Add Two Numbers
- 09-19Java 哈希表运用-LeetCode 1 Two Sum
- 09-19leetcode 1. Two Sum [java]