As reported: Uber L5A Senior Software Engineer loop (India, 2025), round 2 (DSA): the next greater palindrome of a given number — mirroring plus carry propagation; a working solution was reached by the end of the hour. Also the onsite DSA round of an Uber SDE-2 loop (2025), where the DSA rating was a strong yes.
Given a positive integer num as a decimal string, return the smallest palindrome strictly greater than num, also as a string.
Example 1
num = "123"
Output: "131"
Example 2
num = "1221"
Output: "1331"
Example 3
num = "999"
Output: "1001"
Constraints: 1 ≤ num.length ≤ 10^5; num has no leading zeros and represents a value ≥ 1.
Code runner format: one JSON value per line: num. Implement nextPalindrome(num); the harness prints the returned string.