digits holding a huge palindromic number (it reads the same left to right and right to left).
Rearrange its digits into another palindrome: the smallest one that is strictly greater than the original number. Return it as a string. If there is no such palindrome, return the empty string.digits='3443' → '4334'
The digits 3, 3, 4, 4 form the palindromes 3443 and 4334; the next one after 3443 is 4334.
digits='97179' → ''
The middle 1 has to stay put, and the left half "97" cannot be made larger by reordering, so the answer is the empty string.
digits='1235321' → '1325231'
The left half "123" becomes its next arrangement "132", and the number is mirrored: 1325231.
len(digits) ≤ 10⁵digits consists of digits and is a palindromedigits='3443'
'4334'
Run checks the first 3 tests in your browser. Submit checks all 121 tests on the server, hidden ones included.