Number Reversal
InterviewTime limit1sMemory limit128 MB
For each number, reverse its digits, add to the original, and print YES if the sum is a palindrome, else NO.
- Level
Easy2 of 10
- Topics
- String, Math, Implementation
- Solved
- No attempts yet
Problem
For each test case, an integer N is given. Let R be the number made by reading the decimal digits of N in reverse order.
Determine whether N + R is a palindrome, meaning it reads the same from left to right and from right to left. Any leading zeros that appear after reversing are discarded when R is interpreted as an integer.
Input
The first line contains the number of test cases T. Each of the next T lines contains one integer N.
10 <= N <= 100000
Output
For each test case, print YES if the sum of the original number and its reversed number is a palindrome. Otherwise, print NO.