leetcode 231. Power of Two

wonderful world·2021년 12월 21일
0

leetcode

목록 보기
11/21

https://leetcode.com/problems/power-of-two/submissions/

class Solution:
    def isPowerOfTwo(self, n: int) -> bool:
        while n > 1:
            remainder = n % 2
            if remainder != 0:
                return False
            n = n // 2
        
        return n == 1
profile
hello wirld

0개의 댓글