tags::
type:: Leetcode_Solution
in:: Algorithms MOC
approach 1 - brute force with heap
- simulate the cpu
- make a timer, make a cooldown deque, make a heap of tasks to perform
approach 2 - greedy
- the time it task to complete the tasks is
len(tasks) + idle
. - the optimal approach is to cycle tasks based on the gap, using the most frequent task (A) as the decider
- Eg: A---A---A---A
- and then insert other tasks as evenly as possible as well:
- ABCDAB-DAB--A
- since every other task has a lower frequency of A, you can put 1 task per gap
- if you still have spaces, you have idle time. if not, then you have no idle time