Skip to content

Instantly share code, notes, and snippets.

@Ni55aN
Created November 2, 2017 18:45
Show Gist options
  • Save Ni55aN/5ef84d86bfd9f4d618bc6378b5f4295c to your computer and use it in GitHub Desktop.
Save Ni55aN/5ef84d86bfd9f4d618bc6378b5f4295c to your computer and use it in GitHub Desktop.
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