[LeetCode]Power of Two
public class Solution { public boolean isPowerOfTwo(int n) { int tmp = 1; for (int j = 0; j < 32; j++) { if (n == tmp) { return true; } if (tmp > n) { return false; } tmp = tmp << 1; } return false; } }
public class Solution { public boolean isPowerOfTwo(int n) { int tmp = 1; for (int j = 0; j < 32; j++) { if (n == tmp) { return true; } if (tmp > n) { return false; } tmp = tmp << 1; } return false; } }