原题链接:https://leetcode.com/problems/power-of-two/
Description
Given an integer, write a function to determine if it is a power of two.
水一发python。。
class Solution(object):
def isPowerOfTwo(self, n):
shift = 1
if n == 1 or n == 2:
return True
while shift < n:
shift <<= 1
return shift == n