A Python Solution


  • 0
    1
    class Solution(object):
        def isPowerOfTwo(self, n):
            """
            :type n: int
            :rtype: bool
            """
            while int(n) == n and n > 1:
                n = n / 2.0
            return n == 1
    

Log in to reply
 

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