Skip to content

Instantly share code, notes, and snippets.

@AsifITk
Created September 9, 2022 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsifITk/82045efa3b50cd6fcdd6491f44dec9e7 to your computer and use it in GitHub Desktop.
Save AsifITk/82045efa3b50cd6fcdd6491f44dec9e7 to your computer and use it in GitHub Desktop.
let avgWaitTime = function (customers) {
let total = 0;
let end = 0;
for (let i = 0; i < customers.length; i++) {
end = Math.max(end + customers[i][1], customers[i][0] + customers[i][1]);
total += end - customers[i][0];
}
return (total / customers.length).toFixed(5);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment