#12Ancient Vault Code
EasySimulationNumber ManipulationMathTwo Pointers
Deep inside an ancient temple lies a mysterious vault protected by a numeric code.
The vault opens only when the code reads exactly the same from left to right and right to left.
Given an integer code, return true if it is a valid vault code, and false otherwise.
A negative code is not considered valid because the negative sign does not appear at the end when the number is reversed.
Examples
Example 1
Input: 9229
Output: true
Explanation: 9229 reads the same forward and backward.
Example 2
Input: 252
Output: true
Explanation: 252 reads the same forward and backward.
Constraints
- -2^31 <= code <= 2^31 - 1
- code is a valid 32-bit signed integer.
