Python easy solution using While


  • 0
    5
    def isPowerOfTwo(self,n):
        x=1
        y=1
        while y<=n:
            if y==n:
                return True
            else:
                y=2**x
                x+=1
        return False
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.