Python Solution


  • 1
    X
    class Solution:
        # @param {integer} n
        # @return {boolean}
        def isPowerOfTwo(self, n):
            if n <= 0:
                return False
            if n == 1:
                return True
            while n > 1:
                if n%2 == 0:
                    n = n/2
                else:
                    return False
            return True

  • 0
    W
    This post is deleted!

Log in to reply
 

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