其他分享
首页 > 其他分享> > LeetCode——231.2的幂

LeetCode——231.2的幂

作者:互联网

class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        # num = 0
        # for i in range(100):
        #     num = 2**i
        #     if num==n:
        #         return True
        #     if num>n:
        #         return False

        # if n == 0:
        #     return False
        # while n % 2 == 0:
        #     n /= 2
        # return n == 1

        if n == 0:
            return False
        return n & (n - 1) == 0

标签:False,幂次,二进制,的话,231.2,num,return,LeetCode
来源: https://blog.csdn.net/weixin_37724529/article/details/113455045