Given an integer x, return true if x is a palindrome, and false otherwise. An integer is a palindrome when it reads the same forward and backward. For example, 121 is a palindrome while 123 is not.
Example 1
Input: x = 1221
Output: true
Explanation: 1221 reads the same forwards and backwards. Reversing its back half, 21, gives 12, which matches the front half.
Example 2
Input: x = 121
Output: true
Explanation: 121 reversed is still 121, so it is a palindrome.
Example 3
Input: x = -121
Output: false
Explanation: Reading -121 backwards gives 121-, which is not the same, so negative numbers are never palindromes.
Reverse only the second half of the number and compare it to the first half — no string conversion, and no risk of integer overflow from reversing the whole number.
Run checks all cases above. Submit evaluates all test cases.