621. Task Scheduler——python——array

 

class Solution(object):
    def kthSmallest(self, tasks, n):
        dic = collections.Counter(tasks)
        maxcount = max(dic.values())
        count = 0
        for i in dic.keys():
            if dic[i] == maxcount:
                count += 1
        return max(len(tasks), (n+1)*(maxcount-1)+count)    # 先把最多的字母安排好

相关文章:

  • 2021-12-07
  • 2022-01-01
  • 2022-12-23
  • 2022-01-07
  • 2021-11-24
  • 2021-04-16
  • 2021-08-26
猜你喜欢
  • 2021-11-29
  • 2021-06-20
  • 2021-12-21
  • 2022-12-23
相关资源
相似解决方案