Practice/Meta/Leetcode 9. Palindrome Number
CodingMust
Given an integer, determine whether its digits form a symmetric sequence that reads the same from left to right as it does from right to left.
Negative numbers should always return false since the negative sign only appears at the beginning.
true if the integer's digits are symmetric (palindromic), false otherwisefalsetrue-2^31 <= x <= 2^31 - 1 (standard 32-bit signed integer range)Example 1:
Input: x = 121 Output: true Explanation: Reading from left to right gives 1-2-1, and reading from right to left also gives 1-2-1
Example 2:
Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it would be 121-, which is not the same
Example 3:
Input: x = 10 Output: false Explanation: Reading from right to left gives 01, which is different from 10
Example 4:
Input: x = 0 Output: true Explanation: Zero is symmetric