Archived

power of two

An old note — I haven't updated it since I wrote it.
1from math import log2
2class Solution:
3    def isPowerOfTwo(self, n: int) -> bool:
4        if n > 0:
5            l = log2(n)
6            return (l - int(l)) == 0