15% off all plans & roadmaps Use code
See plansLeetCode 9 · Solution & editorial
Given an integer x, return true if x is a palindrome, and false otherwise.
Palindrome Number is a String Manipulation Patterns problem, in the Palindrome Check (Two Pointers / Reverse) subpattern. The pattern covers palindrome checking, anagram detection, pattern matching, and string conversion
Master palindrome checking using two pointers. Handle valid palindrome with alphanumeric and one removal cases.
The reference solution runs in O(log_{10} n) time and O(1) space.
Palindrome Number has been reported in interviews at Microsoft, Adobe, Bloomberg, Facebook, Google, Yahoo.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Palindrome Number is a String Manipulation Patterns problem, in the Palindrome Check (Two Pointers / Reverse) subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.