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
4mo

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!
Select
Add answer anonymously...

ZIGRAM Software Developer interview questions & answers

A Software Developer was asked Q. Rotting Oranges Problem Statement You are given a grid containing oranges where ...read more
A Software Developer was asked Q. Sort a Stack Problem Statement You are given a stack. Your task is to sort the e...read more
A Software Developer was asked Q. Hourglass Pattern Problem Statement Given an integer 'N', print an hourglass pat...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. Rotting Oranges Problem Statement You are given a grid containing oranges where ...read more
A Software Developer was asked Q2. Sort a Stack Problem Statement You are given a stack. Your task is to sort the e...read more
A Software Developer was asked Q3. Hourglass Pattern Problem Statement Given an integer 'N', print an hourglass pat...read more
ZIGRAM Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits