LN : leetcode 231 Power of Two
lc 231 Power of Two
Given an integer, write a function to determine if it is a power of two.
analysation##
Easy problem.
solution
bool isPowerOfTwo(int n) {
  if (n <= 0)
  return false;
  while (n%2 == 0)
  n = n>>1;
  return (n == 1);
}
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号