HTMLify
LeetCode - Number of Even and Odd Bits - Python
Views: 301 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 | class Solution: def evenOddBit(self, n: int) -> List[int]: ans = [0, 0] for i, v in enumerate(bin(n)[2:][::-1]): if v == "0": continue if i%2: ans[1] += 1 else: ans[0] += 1 return ans |