singularity

1701. Average waiting time

O(n)

avg waiting time

var averageWaitingTime = function (customers) {
    let res=0, now=0;

    for(let [arr,prep] of customers){
        now = Math.max(now, arr)
        now += prep
        res += now - arr
    }

    return res/customers.length
};