[JavaScript] Max Heap Approach O(N logN) Time
Time: O((N + M) * logN) where N is # of  classes and M is # of extraStudents\nSpace: O(N)\njavascript\nvar maxAverageRatio = function(classes, extraStudents) {\
Time: `O((N + M) * logN)` where `N` is # of  `classes` and `M` is # of `extraStudents`\nSpace: `O(N)`\n```javascript\nvar maxAverageRatio = function(classes, extraStudents) {\n    const heap = new MaxPriorityQueue({priority: x => x[2]});\n    \n    for(let [pass, total] of classes) {\n        const before = pass/total;\n        const after = (pass+1)/(total+1)\n        heap.enqueue([pass, total, after-before]);\n    }\n    \n    while(extraStudents--) {\n        let [pass, total] = heap.dequeue().element;\n        pass++;\n        total++;\n        const before = pass/total;\n        const after = (pass+1)/(total+1);\n        heap.enqueue([pass, total, after-before]);\n    }\n    \n    let sum = 0;\n    \n    while(!heap.isEmpty()) {\n        const [pass, total] = heap.dequeue().element;\n        sum += (pass/total);\n    }\n    return sum/classes.length;\n};\n```
['Heap (Priority Queue)', 'JavaScript']