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.
Be the first one to answer
Add answer anonymously...
Nagarro Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter