leetcode1009】的更多相关文章

Every non-negative integer N has a binary representation.  For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on.  Note that except for N = 0, there are no leading zeroes in any binary representation.…
class Solution: def bitwiseComplement(self, N: int) -> int: if N==0: return 1 elif N==1: return 0 s = list() while N!=0: re = N%2 if re==0: re=1 else: re = 0 s.append(re) N=N//2 sums = 0 for i in range(len(s)): cur = int(s[i]) cur = cur * pow(2,i) su…