dsa1 min read
Task Scheduler — Greedy with Most Frequent First
Find the minimum intervals to execute all tasks with cooldown n by greedily scheduling the most frequent task first.
Read →
1575 articles
Find the minimum intervals to execute all tasks with cooldown n by greedily scheduling the most frequent task first.
Find minutes until all oranges rot using multi-source BFS starting from all initially rotten oranges simultaneously.
Count islands in a 2D grid using BFS or DFS to flood-fill connected land cells, marking them visited.
Detect if all courses can be finished (no cycle) using Kahn's algorithm: BFS on in-degree zero nodes.
Return a valid course order using Kahn's BFS topological sort, or empty array if a cycle exists.