easy
math
Return whether the decimal digits of integer x read the same left-to-right and right-to-left. Negative values are not palindromes.
Input / output
- Input:
x: integer - Output: boolean
Examples
121returnstrue.-121and10returnfalse.
Constraints
-2,147,483,648 <= x <= 2,147,483,647
Follow-up Can you reverse only half the digits to avoid strings and integer overflow?
Examples
Example 1
Input: x = 121
Output: true
Example 2
Input: x = -121
Output: false
Example 3
Input: x = 10
Output: false
🔒 5 hidden
Running will execute all 8 cases, including 5 hidden ones.