Next Smallest Palindrome!

Problem Description

Given a numeric string A representing a large number you need to find the next smallest palindrome greater than this number.

Problem Constraints

1 <= |A| <= 100

A doesn't start with zeroes and always contain digits from 0-9.

Input Format

First and only argument is an string A.

Output Format

Return a numeric string denoting the next smallest palindrome greater than A.

Example Input

Input 1:

 A = "23545"

Input 2:

 A = "999"

Example Output

Output 1:


Output 2:


NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Next Smallest Palindrome! on Interview Code Editor
  • Hint 1
  • Solution Approach
  • Complete Solution
Asked In:


Click here to start solving coding interview questions