Advertisement
arvind_iyer_2001

Untitled

Jun 19th, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. class Solution:
  2.     def leastInterval(self, tasks: List[str], n: int) -> int:
  3.         d = {}
  4.         m = 0
  5.         for i in range(len(tasks)):
  6.             if(tasks[i] not in list(d.keys())):
  7.                 d[tasks[i]] = 0
  8.             d[tasks[i]] += 1
  9.             if(m< d[tasks[i]]):
  10.                 m = d[tasks[i]]
  11.         a = 0
  12.         for k in list(d.keys()):
  13.             if(d[k] == m):
  14.                 a += 1
  15.         return max(m + a - 1 + (m-1)*n, len(tasks))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement