Problem 81
Palindrome Number
Easy · 10 pts · Math
Problem
You are given an integer N. Decide whether it is a palindrome: whether its decimal digits read the same forwards and backwards. Negative numbers are never palindromes, because the minus sign appears only at the front. You can convert N to a string and compare it with its reverse, or build the reversed number arithmetically (repeatedly taking N mod 10) and compare it with the original.
Input
A single integer N.
Output
Print YES or NO.
Constraints
-2^31 <= N <= 2^31 - 1
Example input
121
Example output
YES
Explanation
121 read backwards is still 1, 2, 1, so it is a palindrome and the answer is YES.