MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / Solution

Class Solution

Python/621-Task-Scheduler.py:20–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class Solution:
21 def leastInterval(self, tasks: List[str], n: int) -> int:
22 counter=Counter(tasks)
23 freq=sorted(list(counter.values()))
24
25 max_idle=freq.pop()
26 total=(max_idle-1)*n
27
28 while freq and total>0:
29 total=total-min(max_idle-1,freq.pop())
30
31 total=max(0,total)
32 return len(tasks) + total

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected