Given a non-negative integer n. Reverse the bits of n and print the number obtained after reversing the bits. 
Note:  The actual binary representation of the number is being considered for reversing the bits, no leading 0’s are being considered.
 
Example 1:
Input : 
N = 11
Output:
13
Explanation:
(11)_{10} = (1011)_{2}.
After reversing the bits we get:
(1101)_{2} = (13)_{10}.
Example 2:
Input : 
N = 10
Output:
5
Explanation:
(10)_{10} = (1010)_{2}.
After reversing the bits we get:
(0101)_{2} = (101)_{2}
        = (5)_{10}.
Your task:
You don't need to read input or print anything. Your task is to complete the function reverseBits() which takes an integer N as input and returns the number obtained after reversing bits.
 
Expected Time Complexity : O(number of bits in the binary representation of N)
Expected Auxiliary Space :  O(1)
 
Constraints :
1 ≤ N ≤ 10^{9}

Source: geeksforgeeks | Difficulty: EASY

Starter code: #User function Template for python3

class Solution:
    def reverseBits(self,n):
        #code here

Solutions:
class Solution:

	def reverseBits(self, n):
		t = bin(n)[2:]
		p = t[::-1]
		q = int(p, 2)
		return q


class Solution:

	def reverseBits(self, n):
		binary = bin(n)
		rev_binary = binary[::-1]
		rev = rev_binary[:-2]
		num = int(rev, 2)
		return num


class Solution:

	def reverseBits(self, n):
		b = format(n, 'b')
		rev = b[::-1]
		return int(rev, 2)


class Solution:

	def reverseBits(self, n):
		val = bin(n)[2:]
		val = list(val)
		val.reverse()
		val = ''.join(val)
		return int(val, 2)


class Solution:

	def reverseBits(self, n):
		x = bin(n)[2:]
		y = x[::-1]
		z = int(y, 2)
		return z


class Solution:

	def reverseBits(self, n):
		p = str(bin(n))[2:]
		m = p[::-1]
		return int(m, 2)


class Solution:

	def reverseBits(self, n):
		b = bin(n)[2:][::-1]
		return int(b, 2)


class Solution:

	def reverseBits(self, n):
		k = 0
		while n != 0:
			k = k << 1
			k = k | n & 1
			n = n >> 1
		return k


class Solution:

	def reverseBits(self, n):
		ans = 0
		while n > 0:
			ans = ans << 1
			ans = ans + n % 2
			n = n >> 1
		return ans


class Solution:

	def reverseBits(self, n):
		rev = 0
		while n > 0:
			rev = rev << 1
			if n & 1 == 1:
				rev = rev ^ 1
			n = n >> 1
		return rev


class Solution:

	def reverseBits(self, n):

		def countLeftMostSetBitPosition(n):
			x = 0
			while 1 << x <= n:
				x += 1
			return x - 1
		res = 0
		i = countLeftMostSetBitPosition(n)
		while n:
			bit = n & 1
			res |= bit << i
			i -= 1
			n = n >> 1
		return res


class Solution:

	def reverseBits(self, n):
		s = '0b' + bin(n)[2:][::-1]
		return int(s, 2)


class Solution:

	def reverseBits(self, n):
		a = bin(n)[2:][::-1]
		return int(a, 2)


class Solution:

	def reverseBits(self, n):
		bits = []
		while n != 0:
			bits.append(n % 2)
			n = int(n / 2)
		res = 0
		power = 0
		for bit in reversed(bits):
			if bit == 1:
				res += bit * 2 ** power
			power += 1
		return res


class Solution:

	def reverseBits(self, n):
		s = ''
		while n:
			if n & 1:
				s = s + '1'
			else:
				s = s + '0'
			n = n >> 1
		return int(s, 2)


class Solution:

	def reverseBits(self, n):
		s = ''
		while n:
			s += str(n & 1)
			n = n >> 1
		return int(s, 2)


class Solution:

	def reverseBits(self, n):
		res = 0
		while n:
			s = n & 1
			n >>= 1
			res |= s
			res <<= 1
		return res // 2


class Solution:

	def reverseBits(self, X):
		x = bin(X)[2:]
		return int(x[::-1], 2)


class Solution:

	def reverseBits(self, x):
		t = 0
		while x:
			t |= x & 1
			t <<= 1
			x >>= 1
		return t >> 1


class Solution:

	def reverseBits(self, n):
		return int(bin(n)[::-1].replace('b0', ''), 2)


class Solution:

	def reverseBits(self, n):
		a = format(n, 'b')
		p = a[::-1]
		num = int(p, 2)
		return num


class Solution:

	def reverseBits(self, n):
		bit = []

		def binary(n):
			if n >= 1:
				bit.append(str(n % 2))
				return binary(n // 2)
			else:
				return bit
		binary(n)
		bit_str = ''.join(bit)[::-1]
		sum = 0
		for i in range(0, len(bit_str)):
			if int(bit_str[i]) != 0:
				sum += 2 ** i
		return sum


class Solution:

	def reverseBits(self, n):
		res = []
		while n > 0:
			res.append(n % 2)
			n = int(n / 2)
		n = 0
		for i in res:
			n *= 2
			n += i
		return n


class Solution:

	def reverseBits(self, n):
		a = bin(n).replace('0b', '')
		r = ''
		for i in a:
			r = i + r
		return int(r, 2)


class Solution:

	def reverseBits(self, n):
		bits = bin(n)[2:]
		return int(bits[::-1], 2)


class Solution:

	def reverseBits(self, n):
		ans = 0
		while n != 0:
			ans = ans * 10 + n % 2
			n = n // 2
		ans = str(ans)
		count = 0
		res = 0
		for i in range(len(ans) - 1, -1, -1):
			if ans[i] == '1':
				res += pow(2, count)
			count += 1
		return res


class Solution:

	def reverseBits(self, n):
		b = bin(n)
		s = str(b).replace('0b', '')
		l = list(s)
		l.reverse()
		s1 = ''.join(map(str, l))
		i = int(s1, 2)
		return i


class Solution:

	def reverseBits(self, n):
		l = str(bin(n))[2:]
		l = l[::-1]
		return int(l, 2)


class Solution:

	def reverseBits(self, n):
		a = bin(n)
		a = a[2:]
		b = a[::-1]
		while b[0] == 0:
			b = b[1:]
		return int(str(b), 2)


class Solution:

	def reverseBits(self, n):
		ans = 0
		while n > 0:
			ans = ans << 1
			if n & 1 == 1:
				ans = ans ^ 1
			n = n >> 1
		return ans


class Solution:

	def reverseBits(self, n):
		bin = 0
		num = n
		while num > 0:
			rem = num % 2
			bin = bin * 10 + rem
			num = num // 2
		pw = 0
		dn1 = 0
		while bin > 0:
			rem = bin % 10
			dn1 = dn1 + rem * pow(2, pw)
			pw += 1
			bin = bin // 10
		return dn1


class Solution:

	def reverseBits(self, n):
		s = bin(n)
		s = s[2:]
		s = s[::-1]
		d = len(s) - 1
		c = 0
		for i in s:
			if i == '1':
				c += 2 ** d
			d -= 1
		return c


class Solution:

	def reverseBits(self, n):
		bin = 0
		while n > 0:
			bin = bin * 10 + n % 2
			n = n // 2
		bin = str(bin)
		val = 0
		k = 0
		for i in range(len(bin) - 1, -1, -1):
			val += int(bin[i]) * 2 ** k
			k += 1
		return val


class Solution:

	def reverseBits(self, n):
		a = '{:0b}'.format(n)
		return int(a[::-1], 2)


class Solution:

	def reverseBits(self, n):
		res = 0
		while n > 0:
			res = res | n & 1
			res = res << 1
			n = n >> 1
		return res >> 1


class Solution:

	def reverseBits(self, n):
		x = bin(n)
		x = x[2:]
		x = x[::-1]
		return int(x, 2)
import math

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		ob = Solution()
		print(ob.reverseBits(n))
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def reverseBits(self, n):
		b = bin(n).replace('0b', '')
		c = b[::-1]
		i = int(c, 2)
		return i
import math

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		ob = Solution()
		print(ob.reverseBits(n))
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def intTobin(self, num):
		ans = ''
		while num:
			ans += str(num % 2)
			num = num // 2
		return ans[::-1]

	def binToint(self, bin):
		ans = 0
		for i in range(len(bin)):
			ans += int(bin[i]) * 2 ** i
		return ans

	def reverseBits(self, n):
		return self.binToint(self.intTobin(n))
import math

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		ob = Solution()
		print(ob.reverseBits(n))
		T -= 1
if __name__ == '__main__':
	main()


def decimalToBinary(n):
	return bin(n).replace('0b', '')

class Solution:

	def reverseBits(self, n):
		a = decimalToBinary(n)
		gg = list(a)
		gg = gg[::-1]
		a = ''.join(gg)
		return int(a, 2)
import math

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		ob = Solution()
		print(ob.reverseBits(n))
		T -= 1
if __name__ == '__main__':
	main()


import math

class Solution:

	def reverseBits(self, n):
		msb = int(math.log2(n))
		ans = 0
		for i in range(msb + 1):
			if n & 1 << i:
				ans += 1 << msb - i
		return ans
import math

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		ob = Solution()
		print(ob.reverseBits(n))
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def reverseBits(self, n):
		s = ''
		while n > 0:
			s += str(n % 2)
			n = int(n / 2)
		s.lstrip('0')
		s = s[::-1]
		p = 0
		res = 0
		for i in s:
			res += int(i) * 2 ** p
			p += 1
		return res
import math

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		ob = Solution()
		print(ob.reverseBits(n))
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def reverseBits(self, n):
		m = bin(n)[2:]
		k = m[::-1]
		return int(k, 2)


class Solution:

	def reverseBits(self, n):
		c = ' '
		m = 0
		j = 0
		while n > 0:
			if n & 1 == 1:
				c += '1'
			else:
				c += '0'
			n = n >> 1
		for i in range(len(c) - 1, -1, -1):
			if c[i] == '1':
				m += 2 ** j
			j = j + 1
		return m


class Solution:

	def reverseBits(self, n):
		a = []
		(j, dec, decimal) = (0, 0, 0)
		s = ' '
		while n > 0:
			a.append(n % 2)
			n = int(n / 2)
		for i in a:
			s = s + str(i)
		s = int(s)
		while s != 0:
			dec = s % 10
			decimal = decimal + dec * pow(2, j)
			s = s // 10
			j = j + 1
		return decimal


class Solution:

	def reverseBits(self, n):
		a = bin(n).replace('0b', '')
		b = a[::-1]
		return int(b, 2)


class Solution:

	def reverseBits(self, n):
		ans = []
		while n > 0:
			if n & 1:
				ans.append(1)
			else:
				ans.append(0)
			n = n >> 1
		res = 0
		for i in range(len(ans)):
			if ans[i] == 1:
				res += pow(2, len(ans) - i - 1)
		return res


class Solution:

	def reverseBits(self, n):
		bit = []
		while n > 0:
			bit.append(n % 2)
			n = n // 2
		for (i, ele) in enumerate(bit[::-1]):
			n += ele * 2 ** i
		return n


class Solution:

	def reverseBits(self, n):
		d = bin(n)[2:]
		d = d[::-1]
		return int(d, 2)


class Solution:

	def reverseBits(self, n):
		k = bin(n)[2:]
		x = int(k)
		t = 0
		count = 0
		temp = 0
		while x > 0:
			temp = temp * 10 + x % 10
			x = x // 10
			count = count + 1
		i = 0
		while i < count + 1:
			t = t + temp % 10 * pow(2, i)
			temp = temp // 10
			i = i + 1
		return t


class Solution:

	def reverseBits(self, n):
		x = bin(n).replace('0b', '')
		s = str(x)[::-1]
		y = int(s, 2)
		return y