Created
November 2, 2017 18:45
-
-
Save Ni55aN/5ef84d86bfd9f4d618bc6378b5f4295c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function queueTime(customers, n) { | |
var sorted = customers.sort((a,b)=>b-a); | |
var max = Math.max(...sorted); | |
var tills = Array(n).fill(0); | |
while(sorted.length>0){ | |
for(var i=0;i<n && i<sorted.length;i++) | |
{ | |
tills[i] += sorted.shift(); | |
} | |
tills = tills.sort((a,b)=>a-b); | |
} | |
return Math.max(...tills); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment