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
aquib_ansari:
20180715 17:44:49
Do we need to consider ve numbers as well? 

shivansh306:
20180715 12:39:04
Run time error in python3 I am defining a function for solving the problem 

rogu_auto:
20180713 16:25:02
pay attention to "K of not more than 1000000 digits"! u can't use a numeric variable to save K, u need a string variable! 

phuongnguyen96:
20180711 11:19:55
runtime error. i don't understand, with java!!


mrzydeco:
20180708 06:38:12
The hapless solver of this solver of this problem might have quite reasonably assumed that the input would consist only of digits and newline characters. If you're going to allow stray whitespace at the beginning or end of input lines, that should be mentioned in the input specification.


piyushonkar:
20180702 09:40:38
It is showing correct output for 99 and 999. But when I submit the solutuion it says wrong answer. Can someone post the good test cases? Thank You in advance. 

wrzoboo:
20180622 16:44:31
@badman98 you want to avoid using int(hugenumber) and try the approach of int(hugenumber[1]), think about how addition works in principle, replacing some substring (of length much lower than the entire string which shortens the execution) with some other substring. I hope you'll figure this out :).


badman98:
20180615 11:32:51
@wrzoboo what do u mean by writing own custom function to add 1 how else we can do it without converting string to integer 

kieukhanhmta:
20180610 08:38:06
Hi all!


sonuexpc:
20180609 14:45:21
AC in second go... 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 