public class Solution {
public boolean isPowerOfTwo(int n) {
if (n <= 0) {
return false;
}
while ((n & 1) == 0) {
n = n >> 1;
}
if ((n ^ 1) == 0) {
return true;
} else {
return false;
}
}
}
Power of Two
最新推荐文章于 2022-12-24 18:52:13 发布