Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 986 Bytes

_2365. Task Scheduler II.md

File metadata and controls

40 lines (28 loc) · 986 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 29, 2024

Last updated : June 29, 2024


Related Topics : Array, Hash Table, Simulation

Acceptance Rate : 53.35 %


Solutions

Python

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