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
king_rohan12:
20190609 07:32:18
i'm getting runtime error in java still i'm using string to accept number and long for increment so i'm not getting why it is showing runtime error any body has any idea


hetp111:
20190523 14:06:41
999>1001 

albertark1589:
20190513 06:40:00
Help? Getting SIGABRT. https://ideone.com/oLmbDJ It seems like its passing all the test cases mentioned here in the comments though. Last edit: 20190513 07:30:55 

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 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 