`

Power of Two

 
阅读更多

Given an integer, write a function to determine if it is a power of two.

class Solution(object):
    def isPowerOfTwo(self, n):
        """
        :type n: int
        :rtype: bool
        """
        return True if not n&(n-1) and n != 0 else False

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics