My smart solution in Python using library function!Easy to understand

  • 0

    as you can see.It's so convenient

    class Solution(object):
        def isPowerOfFour(self, num):
            if num<=0:
                return False
            return len(s)%2==1 and s.count('1')<=1

    if num is power of four, its binary form must only include only 1 and the length of it must satisfy length%2==1.

Log in to reply

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