Palindrome Number
EasyP2Coding
Given an integer x, return true if it reads the same forwards and backwards in base 10, otherwise false.
Negative numbers are never palindromes because of the minus sign. Try to solve it without converting the number to a string.
Example 1
- Input
- x = 121
- Output
- true
Example 2
- Input
- x = -121
- Output
- false
Example 3
- Input
- x = 10
- Output
- false
Constraints
- -2^31 <= x <= 2^31 - 1
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.