358. Rearrange String k Distance Apart
s = "aabbcc", k = 3
Result: "abcabc"
The same letters are at least distance 3 from each other.s = "aaabc", k = 3
Answer: ""
It is not possible to rearrange the string.s = "aaadbbcc", k = 2
Answer: "abacabcd"
Another possible answer is: "abcabcda"
The same letters are at least distance 2 from each other.Last updated
Was this helpful?