2023-12-09 18:42:21 +08:00
< p > Given an integer < code > x< / code > , return < code > true< / code > < em > if < / em > < code > x< / code > < em > is a < / em > < span data-keyword = "palindrome-integer" > < em > < strong > palindrome< / strong > < / em > < / span > < em > , and < / em > < code > false< / code > < em > otherwise< / em > .< / p >
2022-03-27 18:43:57 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:43:57 +08:00
< pre >
< strong > Input:< / strong > x = 121
< strong > Output:< / strong > true
< strong > Explanation:< / strong > 121 reads as 121 from left to right and from right to left.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:43:57 +08:00
< pre >
< strong > Input:< / strong > x = -121
< strong > Output:< / strong > false
< strong > Explanation:< / strong > From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 18:43:57 +08:00
< pre >
< strong > Input:< / strong > x = 10
< strong > Output:< / strong > false
< strong > Explanation:< / strong > Reads 01 from right to left. Therefore it is not a palindrome.
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > -2< sup > 31< / sup > < = x < = 2< sup > 31< / sup > - 1< / code > < / li >
< / ul >
< p > < / p >
< strong > Follow up:< / strong > Could you solve it without converting the integer to a string?