

class Solution(object):
    def findComplement(self, num):
        """
        :type num: int
        :rtype: int
        """
        return 2 ** (len(bin(num)) - 2) - 1 - num


class Solution2(object):
    def findComplement(self, num):
        i = 1
        while i <= num:
            i <<= 1
        return (i - 1) ^ num



class Solution(object):
    def findComplement(self, num):
        """
        :type num: int
        :rtype: int
        """
        return 2 ** (len(bin(num)) - 2) - 1 - num


class Solution2(object):
    def findComplement(self, num):
        i = 1
        while i <= num:
            i <<= 1
        return (i - 1) ^ num


class Solution3(object):
    def findComplement(self, num):
        bits = '{0:b}'.format(num)
        complement_bits = ''.join('1' if bit == '0' else '0' for bit in bits)
        return int(complement_bits, 2)

Add another solution for 'Number complement' problem
Add another solution for 'Number complement' problem

  
  
  class Solution(object):
      def findComplement(self, num):
          """
          :type num: int
          :rtype: int
          """
          return 2 ** (len(bin(num)) - 2) - 1 - num
  
  
  class Solution2(object):
      def findComplement(self, num):
          i = 1
          while i <= num:
              i <<= 1
          return (i - 1) ^ num
  
+ 
+ class Solution3(object):
+     def findComplement(self, num):
+         bits = '{0:b}'.format(num)
+         complement_bits = ''.join('1' if bit == '0' else '0' for bit in bits)
+         return int(complement_bits, 2)
+ 
Add another solution for 'Number complement' problem
## Code Before:


class Solution(object):
    def findComplement(self, num):
        """
        :type num: int
        :rtype: int
        """
        return 2 ** (len(bin(num)) - 2) - 1 - num


class Solution2(object):
    def findComplement(self, num):
        i = 1
        while i <= num:
            i <<= 1
        return (i - 1) ^ num

## Instruction:
Add another solution for 'Number complement' problem
## Code After:


class Solution(object):
    def findComplement(self, num):
        """
        :type num: int
        :rtype: int
        """
        return 2 ** (len(bin(num)) - 2) - 1 - num


class Solution2(object):
    def findComplement(self, num):
        i = 1
        while i <= num:
            i <<= 1
        return (i - 1) ^ num


class Solution3(object):
    def findComplement(self, num):
        bits = '{0:b}'.format(num)
        complement_bits = ''.join('1' if bit == '0' else '0' for bit in bits)
        return int(complement_bits, 2)
