#3646
Next Special Palindrome Number
hard · 27.9% accepted · 61 likes · top 6%
backtracking · bit manipulation
Description
You are given an integer n.
A number is called special if:
- It is a palindrome.
- Every digit k in the number appears exactly k times.
Return the smallest special number strictly greater than n.
Solution