Power of Four - python solution-sharing


  • 0
    C
    class Solution(object):
        def isPowerOfFour(self, num):
            """
            :type num: int
            :rtype: bool
            """
            if num<=0:
                return False
            while num%4==0:
                num = num/4
            return True if num==1 else False

  • 0
    Z

    Your code seems to give "multiples" of 4, not power of 4.


Log in to reply
 

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