Idiots solution for Python 3 (100%) no loops/bit manipulation
Take the next power of 2 that is bigger than N, then subtract 1 from it to get the number that has the same leftmost bit, but with all of the bits to the right 
Take the next power of 2 that is bigger than N, then subtract 1 from it to get the number that has the same leftmost bit, but with all of the bits to the right filled. \n\nSubtract N from this number and you will get the bits to the right that are 0 converted to 1, which is what you are looking for, e.g. 010 as input, 011 as the number you calculate, 011-010 = 001. There is only one edge case for this solution at N == 0. \n\n    def bitwiseComplement(self, N: int) -> int:\n        if N == 0: \n            return 1\n        else:\n            return 2**(int(log2(N))+1)-1 - N
[]