Next Special Palindrome Number
You are given an integer n.
A number is called special if:
- It is a palindrome.
- Every digit
kin the number appears exactlyktimes.
Return the smallest special number strictly greater than n.
Example 1
Input
n = 2Output
2222 is the smallest special number greater than 2, as it is a palindrome and the digit 2 appears exactly 2 times.
Example 2
Input
n = 33Output
212212 is the smallest special number greater than 33, as it is a palindrome and the digits 1 and 2 appear exactly 1 and 2 times respectively.
Constraints
- 0 <= n <= 10^15