Tricky python solution without loop


  • 0
    C
    class Solution(object):
        s = set([1, 4, 4**2, 4**3, 4**4, 4**5, 4**6,
                 4**7, 4**8, 4**9, 4**10, 4**11, 4**12,
                 4**13, 4**14, 4**15])
        def isPowerOfFour(self, num):
            """
            :type num: int
            :rtype: bool
            """
            if num < 0:
                return False
            return num in self.s

Log in to reply
 

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