- Type: Array, Divide and conquer
- Approach:
- For an index range of start to end, we can calculate the frequency of each character.
- Then we scan from start to end, find the first character whose frequency is less than k, marked as mid.
- And find the next index whose frequency is larger than k, marked as nextMid.
- For now, we have two ranges which are [start, mid], [nextMid, end].
- Do the recursion.
- Complexity:
- Time: O(n^2)
- Space: O(n)