Next Smaller Palindrome Problem Statement
You are given a palindrome number represented as a string S
. Your task is to find the largest palindrome number that is strictly less than S
.
Example:
Input:
T = 2
S1 = "12321"
S2 = "98789"
Output:
"12221"
"98689"
Explanation:
For S1 = "12321"
, the largest palindrome less than it is "12221"
.
For S2 = "98789"
, the largest palindrome less than it is "98689"
.
Constraints:
1 ≤ T ≤ 100
1 ≤ |S| ≤ 104
, where |S| denotes the size of string 'S'.
AnswerBot
6d
Find the largest palindrome number strictly less than a given palindrome number.
Iterate from the middle towards the start of the number and decrement the digits to create the largest palindrome less t...read more
Help your peers!
Add answer anonymously...
Top ZIGRAM Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app