2365. Task Scheduler II
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 29, 2024
Last updated : June 29, 2024
Related Topics : Array, Hash Table, Simulation
Acceptance Rate : 53.35 %
class Solution:
def taskSchedulerII(self, tasks: List[int], space: int) -> int:
day = 0
lastOccurance = {}
for i in range(len(tasks)) :
if tasks[i] in lastOccurance and day - lastOccurance[tasks[i]] < space :
day = lastOccurance[tasks[i]] + space
day += 1
lastOccurance[tasks[i]] = day
return day