← ALL NOTES
Hash Table

3518. Smallest Palindromic Rearrangement II

A palindrome is pinned down entirely by its first half, so ranking the palindromic rearrangements of s is the same task as ranking the distinct permutations of that half — and the k-th one can be built letter by letter without ever listing a candidate.

Loading…