dsa · easy
Palindrome Number
Given a signed integer x, return whether it reads the same forwards and backwards. Leading zeros do not count; a trailing zero can only appear in 0 itself. Negative values are never palindromes.
Arguments
x— the signed integer to test
Example
121 reads 121 from either end → true.
-121 reads 121- from the right → false.
10 reads 01 from the right → false.
Constraints
-2^31 <= x <= 2^31 - 1
Examples
Example 1
Input: 121 Expected: true
Example 2
Input: -121 Expected: false
Example 3
Input: 10 Expected: false