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