func leastInterval(tasks []byte, n int) int { freq := make([]int, 26) for _, t := range tasks { freq[t-'A']++ } sort.Ints(freq) max, cnt := freq[25], 0 for _, i := range freq { if i == max { cnt++ } } return (max-1)*n + cnt }