Difficulty: Hard
Given a number, in the form of an array num[] containing digits from 1 to 9(inclusive). Find the next smallest palindrome strictly larger than the given number.

The core idea is that a palindrome is determined by its left half. Since we want the smallest number larger than the current one, we should try to change the number as little as possible. The most significant digits are on the left, so we try to keep the left half the same and "mirror" it to the right.
We can break the logic into three main steps:
If the input is 999, the next palindrome isn't just a modification of these digits; it adds a digit: 1001.
Compare the original right half with the mirrored left half to see if mirroring alone is enough.
Example: 13211 Left is 13, Right is 11. Mirroring gives 13231. Since 3 > 1, 13231 > 13211. Done!
→→