LeetCode : Is Power Of Two
Question :
https://leetcode.com/problems/power-of-two/description/
class Solution:
def isPowerOfTwo(self, n: int) -> bool:
return n > 0 and (n & (n - 1)) == 0
n>0 : Simply dictates that zero and negative numbers are not accepted.
(n & ...
is-power-of-two.hashnode.dev1 min read