Greedy
Task scheduler problem
Intuitive: construct string from left to right. Use priority queue to firstly consume most frequent char. When a char is used, it has to wait k time to join the pool again. O(Nlog26) time -> O(N).
Visualization: get most frequent char, fill each slot, e.g.
A B ? ? A B ? ? A B
Last updated