621. Task Scheduler

Information

  • Diffculty: Medium

  • Created: 2019-08-31 20:48:57

  • Last Motified: 2019-08-31 20:48:57

Solution

class Solution:
    def leastInterval(self, tasks: List[str], n: int) -> int:
        counts = collections.Counter(tasks).values()
        m = max(counts)
        mct = list(counts).count(m)
        return max(len(tasks), mct + (n + 1) * (m - 1))