Search
⌘K

Leetcode 358. Rearrange String k Distance Apart

Given a string and integer k, rearrange the characters so that identical characters are at least k positions apart (return an empty string if no valid arrangement exists). The core challenge is a scheduling/frequency problem: you must greedily place the most frequent characters while enforcing a k-length cooldown (often modeled with a max-heap and a waiting queue) to satisfy spacing constraints.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.