Palindrome Number
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The minus sign has no matching suffix. That one line in the Bloomberg Palindrome Number problem, reported in September 2020, tells you the edge case the grader is hiding. You've got an OA coming up and this one looks easy, which is exactly why people burn time on it. Two-pointer thinking applies, either on the string form or by reversing half the digits. It's short, but sloppy edge handling fails tests. If you blank on the half-reversal trick under the clock, StealthCoder runs invisibly on your screen as a safety net and hands you a clean solution in real time.
The problem
Given a signed integer x, return whether its decimal representation reads the same from left to right and right to left. Negative integers are not palindromes. Function isPalindromeNumber(x: int) → boolean Examples Example 1 x = 121 return = true 121 reads identically in both directions. Example 2 x = -121 return = false The minus sign has no matching suffix. Constraints x is a 32-bit signed integer.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Two clean approaches. First, convert to a string and run two pointers inward, comparing characters. That's simple and passes. Second, skip the string: reject negatives, reject any positive number ending in 0 unless it's 0 itself, then reverse digits of the number into a second value until the reversed half is greater than or equal to what's left. Compare for even length, or drop the middle digit with integer division by 10 for odd length. The half-reversal avoids overflow worries on a 32-bit input. The common pitfall is forgetting that 10 and 120 end in zero and can never be palindromes, or reversing the whole number and overflowing. If the interviewer asks for no string conversion, that's your follow-up. StealthCoder is the hedge if the digit loop slips away mid-assessment.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Palindrome Number cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as palindrome number. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Palindrome Number FAQ
How hard is Palindrome Number really?+
Easy. The logic fits in ten lines. What trips people up is the edge cases: negatives, numbers ending in zero, and single digits. If you handle those three explicitly before the main loop, you're done in a few minutes.
What's the trick for the Bloomberg version?+
Reverse only half the digits. Pop digits off x and push them onto a reversed value until reversed is at least x. Then compare reversed to x, or to x divided by 10 for odd length. It avoids strings and overflow.
Can I just convert it to a string?+
Yes, and it passes the examples given. Run two pointers from both ends, or compare the string to its reverse. Only switch to the math approach if the problem says no string conversion or you want the cleaner follow-up answer.
Which edge cases should I test first?+
Test x = 0, which is a palindrome. Test negatives like -121, which are not. Test 10, which fails because of the trailing zero. Test a single digit, and an even-length case like 1221 against an odd one like 121.
How do I prepare in 48 hours for this kind of question?+
Write the string version, then the half-reversal version, from memory twice. Trace 121, 1221, 10, and -121 by hand. Then do a few other easy two-pointer problems so the pattern feels automatic. This one shouldn't take more than a few minutes in the OA.