Check if the binary representation of a number is palindrome or not.
 
Example 1:
Input:
N = 17
Output:
1
Explanation:
(17)_{10 }= (10001)_{2}
Which is pallindrome hence
output is 1.
Example 2:
Input:
N = 16
Output:
0
Explanation:
(16)_{10 }= (10000)_{2}
Which is not pallindrome 
hence output is 0.
Your Task:
You don't need to read input or print anything. Your task is to complete the function isPallindrome() which takes an integer N as input parameters and returns 1 if the binary equivalent of N is a palindrome.
 
Expected Time Complexity: O(log N)
Expected Space Complexity: O(logN)
 
Constraints:
1 <= N <= 10^{18}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(log N)
Expected Auxiliary Space: O(logN)

Starter code:
#User function Template for python3

class Solution:
    def isPallindrome(self, N):
        # code here

Solutions:
class Solution:

	def isPallindrome(self, N):
		n = str(bin(N))[2:]
		if n == n[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		x = bin(N)
		y = x[2:]
		if y == y[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		a = bin(N)
		b = a[2:]
		if b == b[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		s = bin(N)[2:]
		s = s[s.index('1'):]
		i = 0
		j = len(s) - 1
		while i < j:
			if s[i] != s[j]:
				return 0
			i += 1
			j -= 1
		return 1


class Solution:

	def isPallindrome(self, N):
		s = ''
		while N > 0:
			d = N % 2
			s += str(d)
			N = N // 2
		s1 = s[::-1]
		if s == s1:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		b = bin(N)[2:]
		if list(b) == list(reversed(b)):
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		binary = bin(N)
		temp = binary[2:]
		if str(temp) == str(temp[::-1]):
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		new_num = 0
		rem = 0
		x = N
		while x > 0:
			rem = x % 2
			new_num = new_num * 2 + rem
			x = x // 2
		if new_num == N:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):

		def convert(num):
			s = []
			while num > 0:
				rem = num % 2
				s.append(str(rem))
				num = num // 2
			rev = ''.join(s)
			s.reverse()
			orig = ''.join(s)
			if rev == orig:
				return 1
			return 0
		return convert(N)


class Solution:

	def isPallindrome(self, N):
		s = ''
		while N > 0:
			val = N % 2
			s += str(val)
			N = N // 2
		i = 0
		j = len(s) - 1
		while i <= j:
			if s[i] != s[j]:
				return 0
			i += 1
			j -= 1
		return 1


class Solution:

	def isPallindrome(self, N):
		k = 0
		f = 1
		a = []
		while N:
			a.append(N % 2)
			N = N // 2
			k += 1
		i = 0
		while 2 * i < k:
			if a[i] != a[k - i - 1]:
				f = 0
				break
			i += 1
		return f


class Solution:

	def isPallindrome(self, N):
		N = bin(N).replace('0b', '')
		if N == N[::-1]:
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		bt = bin(N)[2:]
		l0 = len(bt)
		l = l0 // 2
		for i in range(0, l):
			if bt[i] != bt[l0 - i - 1]:
				return 0
		return 1


class Solution:

	def isPallindrome(self, N):

		def binarynumber(N):
			return bin(N).replace('0b', '')
		a = binarynumber(N)
		return 1 if str(a) == str(a)[::-1] else 0


class Solution:

	def isPallindrome(self, n):
		a = bin(n)
		a = a[2:len(a)]
		b = a[-1::-1]
		if a == b:
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		bin = format(N, 'b')
		return 1 if bin == bin[::-1] else 0


class Solution:

	def isPallindrome(self, N):
		newDig = bin(N)[2:]
		newDig2 = int(newDig)
		reverseNum = 0
		tempNum = newDig2
		while tempNum > 0:
			lastDig = tempNum % 10
			reverseNum = reverseNum * 10 + lastDig
			tempNum = tempNum // 10
		if reverseNum == newDig2:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		s = '{0:b}'
		n = s.format(N)
		S = n[::-1]
		if n == S:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, n):
		res = ''
		while n != 0:
			rem = str(n % 2)
			res = rem + res
			n = n // 2
		l = 0
		r = len(res) - 1
		while l < r:
			if res[l] != res[r]:
				return int(False)
			l += 1
			r -= 1
		return int(True)


class Solution:

	def isPallindrome(self, N):
		c = bin(N)
		s = c.replace('0b', '')
		k = ''.join(reversed(s))
		if s == k:
			return 1
		else:
			return 0


import math

class Solution:

	def isPallindrome(self, N):
		a = bin(N).replace('0b', '')
		if a == a[::-1]:
			return '1'
		else:
			return '0'


class Solution:

	def isPallindrome(self, n):
		k = bin(n)
		k1 = k[2:]
		if k1 == k1[::-1]:
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		k = bin(N)
		k = k[2:]
		k = str(k)
		if k == k[::-1]:
			return 1
		return 0


import math

class Solution:

	def isPallindrome(self, N):
		s = bin(N)[2:]
		s1 = s[::-1]
		return 1 if s == s1 else 0


class Solution:

	def isPallindrome(self, N):
		s = bin(N)[2:]
		if s == s[::-1]:
			return 1
		return 0


class Solution:

	def Decimal_to_binary(self, N):
		num = ''
		while N > 0:
			num = num + str(N % 2)
			N = N // 2
		rnum = num[::-1]
		return rnum

	def Reverse(self, n):
		rev = 0
		while n > 0:
			rev = rev * 10 + n % 10
			n = n // 10
		return rev

	def isPallindrome(self, N):
		num = ob.Decimal_to_binary(N)
		n = int(num)
		rev_num = ob.Reverse(n)
		if n == rev_num:
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		A = ''
		A = bin(N)[2:]
		A = str(A)
		if len(A) < 1:
			return 0
		flag = True
		if len(A) == 1:
			flag = True
		else:
			for i in range(len(A) // 2):
				if A[i] != A[len(A) - i - 1]:
					flag = False
					break
		if flag == True:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		s = str(bin(N))
		v = s[2:]
		r = ''
		i = len(v) - 1
		while i >= 0:
			r = r + v[i]
			i = i - 1
		if r == v:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, dnum):
		bnum = 0
		mul = 1
		while dnum > 0:
			rem = dnum % 2
			bnum = bnum + rem * mul
			mul = mul * 10
			dnum = int(dnum / 2)
		newnum = str(bnum)
		nn = newnum[::-1]
		if int(nn) == bnum:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		n = bin(N)
		x = n[2:]
		l = len(x)
		i = 0
		flag = 1
		for i in range(l):
			if i >= l // 2:
				break
			if x[i] == x[l - i - 1]:
				flag = flag & 1
			else:
				flag = flag & 0
		return flag


class Solution:

	def isPallindrome(self, N):
		s = ''
		while N:
			if N % 2 == 0:
				s += '0'
			else:
				s += '1'
			N = N // 2
		if s[::-1] == s:
			return 1
		return 0


class Solution:

	def isPallindrome(self, n):
		binary = bin(n)[2:]
		start = 0
		end = len(binary) - 1
		while start < end:
			if binary[start] != binary[end]:
				return 0
			start += 1
			end -= 1
		return 1


class Solution:

	def isPallindrome(self, N):
		n = bin(N)
		s = str(n).replace('0b', '')
		l = list(s)
		l.reverse()
		s1 = ''.join(map(str, l))
		if s == s1:
			return 1
		else:
			return 0


class Solution:

	def binary(self, N):
		temp = N
		num_ = ''
		while temp > 0:
			rem = temp % 2
			num_ += str(rem)
			temp = temp // 2
		return int(num_[::-1])

	def isPallindrome(self, N):
		res = self.binary(N)
		res = str(res)
		if res == res[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		p = bin(N)[2:]
		if p == p[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		bin_N = bin(N)
		bin_Ns = str(bin_N)
		bi = bin_Ns[2:]
		bin_Nsr = bi[::-1]
		if bi == bin_Nsr:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		x = bin(N)[2:]
		t = [i for i in x]
		if t == t[::-1]:
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		n = int(N)
		a = bin(n)
		b = a.replace('0b', '')
		c = str(b)
		d = c[::-1]
		if b == d:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		n = bin(N)
		i = len(n) - 1
		j = 2
		s = 0
		while j < i:
			if n[j] != n[i]:
				s = 1
				break
			j = j + 1
			i = i - 1
		if s == 0:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, N):
		a = bin(N)
		b = a[2:]
		if b == b[::-1]:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, N):
		x = str(bin(N))[2:]
		if x == x[::-1]:
			return 1
		return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, n):
		n = bin(n)[2:]
		ans = 1
		for i in range(len(n) // 2):
			if n[i] != n[len(n) - i - 1]:
				ans = 0
				break
		return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, N):

		def bin(n, res):
			if n == 0:
				return res
			res = str(n % 2) + res
			return bin(n // 2, res)
		res = ''
		test = bin(N, res)
		if test == test[::-1]:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, N):
		s = bin(N)[2:]
		if N == 1:
			return 1
		if len(s) % 2 == 0:
			left_mid = len(s) // 2
			right_mid = left_mid - 1
			while left_mid >= 0:
				if s[left_mid] != s[right_mid]:
					return 0
				left_mid -= 1
				right_mid += 1
			return 1
		else:
			left_mid = len(s) // 2 - 1
			right_mid = left_mid + 2
			while left_mid >= 0:
				if s[left_mid] != s[right_mid]:
					return 0
				left_mid -= 1
				right_mid += 1
			return 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, N):
		binary = bin(N).replace('0b', '')
		ln = len(binary)
		flag = 1
		for i in range(ln // 2):
			if binary[i] != binary[ln - 1 - i]:
				flag = 0
				return flag
		return flag
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isPallindrome(N))


class Solution:

	def isPallindrome(self, n):
		n1 = bin(n)[2:]
		if n1 == n1[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		k = bin(N).replace('0b', '')
		l = k[::-1]
		if k == l:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		l = []
		while N != 0:
			l.append(N % 2)
			N = N // 2
		k = list(reversed(l))
		(i, j) = (0, len(k) - 1)
		while i < j:
			if k[i] == k[j]:
				i += 1
				j -= 1
			else:
				return 0
		return 1


class Solution:

	def isPallindrome(self, N):
		n = []

		def binary(N):
			if N >= 1:
				binary(N // 2)
			n.append(N % 2)
		binary(N)
		n = n[1:]
		if n == n[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isPallindrome(self, N):
		curr = ''
		while N > 0:
			curr = curr + str(N % 2)
			N = N // 2
		if curr == curr[::-1]:
			return 1
		return 0


class Solution:

	def isPallindrome(self, N):
		a = str(bin(N))[2:]
		h = len(a)
		for i in range(int(h / 2) + 1):
			if a[i] != a[h - i - 1]:
				return 0
		return 1


class Solution:

	def isPallindrome(self, n):
		k = bin(n).replace('0b', '')
		j = k[len(k) - 1::-1]
		if j == k:
			return 1
		else:
			return 0