leastInterval = function(tasks, n) {
    const frequencyMap = getFrequencyMap(tasks);
    const maxFrequency = getMaxFrequency(frequencyMap);
    const mostFrequentTask = getMostFrequentTask(frequencyMap, maxFrequency);
    const interval = ((maxFrequency - 1) * (n + 1)) + mostFrequentTask;

    return Math.max(tasks.length, interval);
}
https://leetcode.com/problems/task-scheduler/
Time O(N) | Space O(1)
@param {character[]} tasks
@param {number} n
@return {number}