Skip to content

Commit

Permalink
Time: 369 ms (77.39%) | Memory: 17 MB (79.06%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Mar 19, 2024
1 parent 93c61ac commit 018ee4e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 621-task-scheduler/task-scheduler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution:
def leastInterval(self, tasks: List[str], n: int) -> int:
freq = [0] * 26
for task in tasks:
freq[ord(task) - ord('A')] += 1
freq.sort()
chunk = freq[25] - 1
idle = chunk * n

for i in range(24, -1, -1):
idle -= min(chunk, freq[i])

return len(tasks) + idle if idle >= 0 else len(tasks)

0 comments on commit 018ee4e

Please sign in to comment.