358. Rearrange String k Distance Apart
Given a string s and an integer k, rearrange s such that the same characters are at least distance k from each other. If it is not possible to rearrange the string, return an empty string “”.
- Time : O(nlogk)
- Space : O(1)
c++
1 | class Solution { |