```
public class Solution {
public boolean isPowerOfTwo(int n) {
if(n <= 0) return false;
int cnt = 0;
int tmp = n;
while(tmp != 1) {
tmp = tmp >> 1;
cnt++;
}
tmp = 1 << cnt;
if((tmp|n) == tmp) return true;
return false;
}
}
```