Given a number, in the form of an array Num[] of size N containing digits from 1 to 9(inclusive). The task is to find the next smallest palindrome strictly larger than the given number.
Example 1
Input: N = 11, Num[] = {9, 4, 1, 8, 7, 9, 7, 8, 3, 2, 2}
Output: 9 4 1 8 8 0 8 8 1 4 9
Explanation: Next smallest palindrome is 9 4 1 8 8 0 8 8 1 4 9
Example 2
Input: N = 5, Num[] = {2, 3, 5, 4, 5}
Output: 2 3 6 3 2
Explanation: Next smallest palindrome is 2 3 6 3 2
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
11 9 4 1 8 7 9 7 8 3 2 2
9 4 1 8 8 0 8 8 1 4 9
5 2 3 5 4 5
2 3 6 3 2