Rearrange a string so that in every suffix the counts of any two of its letters differ by at most K — and return the lexicographically smallest such arrangement, or -1.
Rearrange a string so that in every suffix the counts of any two of its letters differ by at most K — and return the lexicographically smallest such arrangement, or -1.
Opens with the full question.