Skip to content

Commit 47ab26b

Browse files
added daily challenge
1 parent 02a097a commit 47ab26b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

621. Task Scheduler.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def leastInterval(self, tasks: List[str], n: int) -> int:
3+
freq = [0] * 26
4+
for task in tasks:
5+
freq[ord(task) - ord('A')] += 1
6+
freq.sort()
7+
chunk = freq[25] - 1
8+
idle = chunk * n
9+
10+
for i in range(24, -1, -1):
11+
idle -= min(chunk, freq[i])
12+
13+
return len(tasks) + idle if idle >= 0 else len(tasks)

0 commit comments

Comments
 (0)