Given a list of 32 bit unsigned integers N. Find X, the unsigned integer you get by flipping bits in the binary representation of N. i.e. unset bits must be set, and set bits must be unset. Also find the binary representation of X in reverse order.
Example 1:
Input: N = 1
Output: 4294967294 01111111111111111111111111111111
Explaination: 
1 as unsigned 32-bits is 00000000000000000000000000000001. 
Flipping its bits we get 11111111111111111111111111111110.
Its binary representation is 4294967294.
Its reverse order is 01111111111111111111111111111111.
 
Example 2:
Input: N = 2
Output: 4294967293 10111111111111111111111111111111
Explaination: 
2 as unsigned 32-bits is 00000000000000000000000000000010. 
Flipping its bits we get 11111111111111111111111111111101.
Its binary representation is 4294967293.
Its reverse order is 1011111111111111111111111111111.
 
Your Task:
You do not need to read input or print anything. Your task is to complete the function flipBits() which takes N as input parameter and returns a list of strings containing two values, X and  binary representation of X in reverse order.
 
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(logN)
 
Constraints:
1 ≤ N < 4294967296

Source: geeksforgeeks | Difficulty: EASY

Starter code: #User function Template for python3



class Solution:

    def flipBits(self, N):

        # code here

Solutions:
class Solution:

	def flipBits(self, N):
		num = 4294967295 - N
		binary_num = bin(num)[2:]
		return (num, ''.join(reversed(['0'] * (32 - len(binary_num)) + list(binary_num))))


class Solution:

	def flipBits(self, N):
		s = bin(N)[2:]
		s = '0' * (32 - len(s)) + s
		i = ''
		for x in s:
			i += str(1 - int(x))
		return [int(i, 2), i[::-1]]


class Solution:

	def flipBits(self, N):
		ans = []
		N = bin(N).replace('0b', '').zfill(32)[::-1]
		N = N.replace('1', '2')
		N = N.replace('0', '1')
		N = N.replace('2', '0')
		ans.append(int(N[::-1], 2))
		ans.append(N)
		return ans


MAX = 4294967295

class Solution:

	def flipBits(self, n):
		ans = MAX - n
		return (ans, bin(ans)[2:][::-1])


class Solution:

	def flipBits(self, N):
		a = '{:032b}'.format(N)
		a = str(a)
		a = a.replace('0', '*')
		a = a.replace('1', '0')
		a = a.replace('*', '1')
		return (int(a, 2), a[::-1])


class Solution:

	def flipBits(self, N):
		s = '{:032b}'.format(N)
		s = s.replace('1', 'A')
		s = s.replace('0', '1')
		s = s.replace('A', '0')
		decimal = int(s, 2)
		l = [decimal, s[::-1]]
		return l


class Solution:

	def flipBits(self, N):
		binary = bin(N)[2:]
		l = len(binary)
		binary = '0' * (32 - l) + binary
		binary = binary.replace('0', 'a').replace('1', '0').replace('a', '1')
		return [int(binary, 2), binary[::-1]]


class Solution:

	def flipBits(self, N):
		out = []
		N = bin(N)
		N = N[2:]
		length = 32 - len(N)
		res = '0' * length + N
		res1 = ''
		for i in res:
			if i == '0':
				res1 += '1'
			else:
				res1 += '0'
		sum = 0
		for i in range(31, -1, -1):
			sum += int(res1[i]) * 2 ** (32 - i - 1)
		out.append(sum)
		out.append(res1[::-1])
		return out