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
wahidmshafin:
2020-05-16 21:00:15
Try for these test cases
|
|
kauai68:
2020-05-10 18:28:28
I've got AC and I don't think that the implementation is difficult. Nice C++ code needs less than 80 lines of code. Last edit: 2020-05-10 18:29:45 |
|
khoaph:
2020-05-10 03:34:49
Thanks @trulyness for the extra test cases
|
|
manishsaini4u:
2020-05-09 05:30:08
can anyone explain what problem says? |
|
meher_24:
2020-05-07 16:17:01
do i just increment the input by one and check if its a palindrome or is there a better and a faster method?
|
|
hritik_1105:
2020-05-07 06:23:05
Its logic is easy but implementation is hard.
|
|
bernard_mocko1:
2020-05-04 01:09:54
When they say, that elements are not more than 1000000 digits, they are not joking, my char array in C was one element to short Last edit: 2020-05-04 01:17:10 |
|
fawad:
2020-04-25 09:54:46
guys, there is space character after input in every line, just take care of it
|
|
harsh_11:
2020-04-19 10:53:17
I am getting wrong answer for my submission, i am unable to figure out why, my code is working fine for the other listed test cases (the ones that are being provided by others in comment section) and it's also working fine for the a large no like 99999999999999 Last edit: 2020-04-19 10:57:50 |
|
trulyness:
2020-04-17 20:31:20
here are the test cases on which your code should work:
|
Added by: | adrian |
Date: | 2004-05-01 |
Time limit: | 2s-9s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 |