Next Smaller Palindrome Problem Statement
You are provided with a palindrome number 'N' presented as a string 'S'. The task is to determine the largest palindrome number that is strictly less than 'N'.
Input:
The first line contains an integer T, the number of test cases.
For each test case, there is one line with a string 'S' which represents the palindrome number.
Output:
For each test case, output a single line containing the string representation of the largest palindrome that is less than 'S'.
Example:
Input:
T = 2
S = '12321'
S = '1000'
Output:
'12221'
'999'
Constraints:
1 <= T <= 100
1 <= |S| <= 104
(where |S| denotes the length of the string S)- The numerical value of 'S' is greater than 0.
Note:
- A palindrome reads the same backward as forward, such as madam, racecar, 1234321.
- A single-digit number is a palindrome.
- The resulting number should not start with leading zeros, except when the answer is 0.

AnswerBot
4mo
Given a palindrome number 'N' as a string, find the largest palindrome number strictly less than 'N'.
Iterate from the middle towards the start and end of the number to find the next smaller palindrome...read more
Help your peers!
Add answer anonymously...
Deutsche Bank Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Query and Matrix Problem Statement You are given a binary matrix with 'M' rows a...read more
A Software Developer Intern was asked Q. Jump Game Problem Statement In this problem, you are given an array ARR consisti...read more
A Software Developer Intern was asked Q. Dijkstra's Shortest Path Problem Given an undirected graph with ‘V’ vertices (la...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Query and Matrix Problem Statement You are given a binary matrix with 'M' rows a...read more
A Software Developer Intern was asked Q2. Jump Game Problem Statement In this problem, you are given an array ARR consisti...read more
A Software Developer Intern was asked Q3. Dijkstra's Shortest Path Problem Given an undirected graph with ‘V’ vertices (la...read more
>
Deutsche Bank Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

