Sunday 23 April 2017

5.The Next Palindrome

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, write the value of the smallest palindrome larger than K to output.
Input
The first line contains an integer, which corresponds to K. Assume that K is less than 200000.
Output
Output consists of a single integer, which corresponds to the smallest palindrome larger than K.
Sample Input 1:
808
Sample Output 1:
818

code:


No comments:

Post a Comment