Tap here to switch tabs
Problem
Submissions

Problem: Rearrange String k Distance Apart

med
30 min
Try to solve the Rearrange String k Distance Apart problem.

Statement

Given a string s and an integer k, rearrange s such that identical characters are separated by a distance of at least k from each other.

If it is impossible to rearrange the string to satisfy this condition, return an empty string "".

Constraints:

  • 1≤1 \leq s.length ≤3imes105\leq 3 imes 10^5

  • s consists of only lowercase English letters.

  • 0≤0 \leq k ≤\leq s.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Rearrange String k Distance Apart

med
30 min
Try to solve the Rearrange String k Distance Apart problem.

Statement

Given a string s and an integer k, rearrange s such that identical characters are separated by a distance of at least k from each other.

If it is impossible to rearrange the string to satisfy this condition, return an empty string "".

Constraints:

  • 1≤1 \leq s.length ≤3imes105\leq 3 imes 10^5

  • s consists of only lowercase English letters.

  • 0≤0 \leq k ≤\leq s.length