My solution in python


  • 0
    C

    class Solution(object):
    def isPowerOfTwo(self, n):
    k='2468'
    if n<=0 :
    return False
    while n>1 :
    if str(n%10) in k :
    n=n/2
    else :
    return False
    return True


Log in to reply
 

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