Given a string of lowercase characters, reorder them such that the same characters are at least distance d from each other.A:
Input: { a, b, b }, distance = 2
Output: { b, a, b }
sort the characters and build the new string from them.
each time, we extract the d chars and add them at the tail of output.
No comments:
Post a Comment