A building's security turnstile issues each visitor a numeric access code. A code is called mirrored if its decimal digits read exactly the same forwards and backwards. A negative code is never mirrored, because the leading minus sign has no matching digit at the other end.
Given one access code, determine whether it is mirrored.
A single line containing one integer x.
Print true if x is mirrored, otherwise print false.
-2147483648 <= x <= 2147483647
Example 1
Input
121
Expected
true
Explanation
The digits "121" read the same forwards and backwards, so the code is mirrored: output true.
Example 2
Input
-121
Expected
false
Explanation
Negative codes are never mirrored regardless of their digits, so output false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →