9. Palindrome Number
easyAsked at IntelDetermine if an integer is a palindrome WITHOUT converting it to a string. Intel asks because the half-reverse approach (reverse only the lower half of digits and compare) is the same pure-arithmetic discipline that lets you write firmware where heap allocation isn't an option.
By Sam K., Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Intel loops.
- Glassdoor (2026-Q1)— Intel SWE phone-screen reports cite palindrome-number with the explicit 'no string conversion' constraint.
- GeeksforGeeks (2025-09)— Intel Interview Experience archives reference the half-reverse + compare approach.
- LeetCode discuss (2025-11)— Intel-tagged in the LC company-frequency listing.
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 = 121trueExplanation: 121 reads as 121 from left to right and from right to left.
Example 2
x = -121falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
Example 3
x = 10falseExplanation: Reads 01 from right to left. Therefore it is not a palindrome.
Approaches
1. String conversion (brute / not the point)
Convert x to a string and compare with its reverse.
- Time
- O(log x)
- Space
- O(log x)
function isPalindromeStr(x) {
if (x < 0) return false;
const s = x.toString();
return s === s.split('').reverse().join('');
}Tradeoff: Easy and correct but defeats the explicit no-string-conversion follow-up. The interviewer is grading the integer-arithmetic version.
2. Reverse half the number (optimal)
Reverse only the lower half of x's digits. Stop when the reversed half is >= the remaining upper half. Compare; ignore the middle digit if length is odd.
- Time
- O(log x)
- Space
- O(1)
function isPalindrome(x) {
// Negative numbers and numbers ending in 0 (except 0 itself) are not palindromes.
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);
}
// x is the upper half, reversed is the lower half (reversed).
// Odd-length case: drop the middle digit by /10.
return x === reversed || x === Math.floor(reversed / 10);
}Tradeoff: Constant space, no overflow even in C/C++ because we only ever reverse HALF the digits (so the reversed value can't exceed sqrt(INT_MAX) digits anyway). The early-termination check `x > reversed` is what halves the loop count.
Intel-specific tips
Intel reviewers grade two things on this problem: (1) you handle the negative + trailing-zero edge case up front (negative is trivially not a palindrome; positive numbers ending in 0 can only be a palindrome if the number is 0 itself); (2) you reverse HALF the digits instead of the whole number. The whole-number reverse can overflow — half-reverse can't. That overflow-safe property is the Intel-flavored systems signal.
Common mistakes
- Reversing the whole number and comparing — works in JS but overflows in C/C++ for inputs near INT_MAX.
- Forgetting the trailing-zero edge case: 10 reversed is 01 = 1, which would falsely match for x = 10.
- Off-by-one on odd-length termination: when x === reversed, x is the upper half; when x === reversed/10, the middle digit got captured in reversed and we drop it.
- Treating negative as 'symmetric around the sign' — the standard definition includes the '-' as a non-matching prefix, so -121 is NOT a palindrome.
Follow-up questions
An interviewer at Intel may pivot to one of these next:
- Palindrome Linked List (LC 234) — half-reverse a linked list and compare.
- Valid Palindrome (LC 125) — string palindrome with alphanumeric filtering.
- Largest Palindrome Product (LC 479) — find the largest palindrome made from the product of two n-digit numbers.
- What if x could be arbitrary-precision (BigInt)? (Same half-reverse algorithm, just on BigInt.)
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why halt when x > reversed?
Initially x has the full digit count and reversed has 0. Each step moves one digit from x to reversed. When reversed >= x, we've processed at least half the digits. For even-length palindromes, x === reversed at the halfway point. For odd-length, reversed has the middle digit extra; drop it via /10.
Why is the trailing-zero check necessary?
If x ends in 0 and x != 0, then for x to be a palindrome it would have to START with 0 — but no positive integer has a leading zero in its canonical representation. So we reject upfront.
Free learning resources
Curated free links for this problem.
More Intel coding interview questions
- 7. Reverse Integer
- 8. String to Integer (atoi)
- 26. Remove Duplicates from Sorted Array
- 50. Pow(x, n)
- 53. Maximum Subarray
- 66. Plus One
- 69. Sqrt(x)
- 70. Climbing Stairs