9. Palindrome Number
easyAsked at BloombergGiven an integer x, return true if x is palindrome. Bloomberg uses this as a follow-up to Reverse Integer — they want to see the without-converting-to-string optimization to test whether you can think about numeric problems numerically.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Bloomberg loops.
- Glassdoor (2026-Q1)— Bloomberg SWE phone screen reports list this as a common follow-up to Reverse Integer.
- Blind (2025-11)— Bloomberg new-grad reports cite the 'without-string-conversion' constraint as the actual grading criterion.
Problem
Given an integer x, return true if x is a palindrome, and false otherwise. Follow-up: Could you solve it without converting the integer to a string?
Constraints
-2^31 <= x <= 2^31 - 1
Examples
Example 1
x = 121trueExample 2
x = -121falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore not a palindrome.
Example 3
x = 10falseApproaches
1. Reverse half the number (optimal, no string)
Reverse only the back half of the digits. Stop when reversed >= remaining. Compare halves.
- Time
- O(log10(x))
- Space
- O(1)
function isPalindrome(x) {
if (x < 0 || (x % 10 === 0 && x !== 0)) return false;
let reversed = 0;
while (x > reversed) {
reversed = reversed * 10 + (x % 10);
x = Math.floor(x / 10);
}
return x === reversed || x === Math.floor(reversed / 10);
}Tradeoff: Bloomberg's preferred answer. Avoids string conversion. The trailing 0 check rules out 10, 100, etc. Reversing only HALF the digits avoids the overflow that Reverse Integer worried about.
2. String reversal
Convert to string, reverse, compare.
- Time
- O(log10(x))
- Space
- O(log10(x))
function isPalindromeString(x) {
if (x < 0) return false;
const s = String(x);
return s === s.split('').reverse().join('');
}Tradeoff: Trivial to write and read. Mention this first if asked for a quick solution, then offer the without-string version as the 'real' answer.
Bloomberg-specific tips
Bloomberg's grading on this is binary: did you solve it WITHOUT a string conversion. The without-string version uses the reverse-half trick — once reversed >= x's remaining digits, you've covered half. State this optimization out loud BEFORE writing code.
Common mistakes
- Forgetting that negative numbers are never palindromes — the minus sign breaks symmetry.
- Reversing the whole number, which can overflow on the 32-bit signed boundary.
- Missing the trailing-zero case: 10 reversed is 1, but 10 is not a palindrome.
Follow-up questions
An interviewer at Bloomberg may pivot to one of these next:
- Palindrome Linked List (LC 234) — reverse second half then compare.
- Valid Palindrome (LC 125) — alphanumeric string version.
- Reverse Integer (LC 7) — the digit-reversal primitive this problem builds on.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why reverse only half?
Reversing the whole number can overflow. Reversing half avoids overflow because each step shortens x and the reversed half can never exceed sqrt(2^31).
How do I handle the odd-length case?
When the loop exits with x === reversed (even length) OR x === Math.floor(reversed / 10) (odd length). The floor strips the middle digit from the reversed half.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Palindrome Number and other Bloomberg interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →