Binary Representation Palindrome
Given a positive integer n, determine if its binary representation is a palindrome. Return true if it is a palindrome and false otherwise.
[ 1 ]
Explanation. The binary representation of `1` is `1`, which is a palindrome.
[ 5 ]
Explanation. The binary representation of `5` is `101`, which is a palindrome.
[ 12 ]
Explanation. The binary representation of `12` is `1100`, which is not a palindrome.
[ 22 ]
Explanation. The binary representation of `22` is `10110`, which is not a palindrome.
[ 255 ]
Explanation. The binary representation of `255` is `11111111`, which is a palindrome.
Follow-up: Can you solve the problem without converting the integer to a binary string?
The input integer will always be a positive number.
- Views
- 10