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) # 先把最多的字母安排好
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) # 先把最多的字母安排好