python 4 lines


  • 0
    F

    from collections import Counter
    class Solution(object):
    def leastInterval(self, tasks, n):
    m = len(tasks)
    c = sorted(Counter(tasks).values(), reverse=True)
    c = [xi-1 if xi==max(c) else xi for xi in c]
    return max(c[0]*(n+1)+m-sum(c), m)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.