Find the Next Larger Palindrome
UberData Scientist · OnsiteLast updated
This question evaluates proficiency in numeric and string manipulation, algorithmic thinking, and edge-case reasoning related to palindromic number generation.
Given a positive integer n, return the smallest integer strictly greater than n whose decimal representation is a palindrome.
A palindrome reads the same from left to right and right to left. Do not allow leading zeros.
Examples:
n = 9->11n = 123->131n = 808->818n = 999->1001
Discuss edge cases such as single-digit inputs, numbers consisting only of 9s, even versus odd digit lengths, and inputs that are already palindromes.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.