Check If Binary Representation of a Number is Palindrome
Given an integer N
, determine if its binary representation is a palindrome.
Input:
The first line contains a single integer ‘T’ representing the number of test cases.
The first and only line of each test case contains a single integer ‘N’ denoting the given integer.
Output:
Return true if the binary representation of the given number is a palindrome. Else return false.
Example:
Input:
T = 2
N = 5
N = 14
Output:
True
False
Explanation:
The binary representation of 5 is "101", which is a palindrome. The binary representation of 14 is "1110", which is not a palindrome.
Constraints:
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 1018
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
AnswerBot
1mo
Check if the binary representation of a number is a palindrome.
Convert the integer to binary representation.
Check if the binary representation is a palindrome by comparing it with its reverse.
Return t...read more
Help your peers!
Add answer anonymously...
Top Nagarro Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Nagarro Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app