231. Power of Two
Power of Two
Solution
public class Solution {
public boolean isPowerOfTwo(int n) {
if(n==0) return false;
if(n == -2147483648) return false;
int temp = n & (n - 1);
return temp == 0;
}
}Last updated