PALIN  The Next Palindrome
A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.
Input
The first line contains integer t, the number of test cases. Integers K are given in the next t lines.
Output
For each K, output the smallest palindrome larger than K.
Example
Input: 2 808 2133 Output: 818 2222
Warning: large Input/Output data, be careful with certain languages
hide comments
uchihasurvivor:
20190428 15:22:12
AC  0.04s


klmo:
20190418 18:49:26
AC in one go :) but 2.76 time in JAVA, can it be faster in java? 

klmo:
20190418 18:46:40
few interesting test case:


solskgaer:
20190409 12:54:09
I tested 4 scenarios: all 9s, the number itself is a palindrome, numbers like 54321 that just need to mirror the left side to right side and numbers like 12345 that need to mirror the left side to right side and deal with carries, my code passed all 4 cases and work with 1 digit numbers and numbers with leading zeros, but I still failed, any help? Last edit: 20190410 04:46:08 

nguyenthehop:
20190403 11:10:18
I need your help. I don't known where i wrong 

shogun420:
20190402 11:25:50
I guess all my test cases are correct..but it shows time limit exceeded..what should I try next?? Last edit: 20190402 11:27:16 

subhashs:
20190328 18:19:31
0.06s 

phoenix2021:
20190323 12:33:32
anyone who has solved the probem in python3.5?


thecyberalien:
20190322 20:01:26
I am getting runtime error (sigsegv). but it is working perfectly in my compiler. 

danfrown:
20190317 07:38:17
I don't get it. After taking all sorts of input, they are saying wrong answer. However, it works perfectly on my editor offline. I have taken into account

Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 