+ 6

Rearrange a string so that all same characters become d distance away

Given a string and a positive integer d. Some characters may be repeated in the given string. Rearrange characters of the given string such that the same characters become d distance away from each other. Note that there can be many possible rearrangements, the output should be one of the possible rearrangements. If no such arrangement is possible, that should also be reported.  Expected time complexity is O(n) where n is length of input string.  Examples: Input: "abb", d = 2 Output: "bab"

1st Feb 2018, 5:32 PM
Nandan HN
Nandan HN - avatar
3 odpowiedzi
+ 4
I'm working on it
1st Feb 2018, 6:26 PM
Nandan HN
Nandan HN - avatar
+ 3
where is your code
1st Feb 2018, 6:19 PM
Waseem Siddiqi
Waseem Siddiqi - avatar
0
i would have ansawerd but sadly could understand
2nd Feb 2018, 2:48 PM
Hassan Ali Hassan
Hassan Ali Hassan - avatar