358. Rearrange String k Distance Apart

Problem

Rearrange a string so that no two adjacent characters are the same, with at least distance k apart.

Given a string s and an integer k, rearrange the string so that no two identical characters are adjacent, and characters of the same type are at least k positions apart. Return the rearranged string, or an empty string if not possible.

Examples
Input: ["aabbcc",3]
Output: "abcabc"
Hints
Related Problems

358. Rearrange String k Distance Apart

Rearrange a string so that no two adjacent characters are the same, with at least distance k apart.