• + 0 comments

    People have already said this, but to reiterate, in order to write this function propery you need to adjust the call:

    const result = serviceLane(width, cases);

    That is for JS, but it seems like other languages have a similar issue. It also appears (based on the examples given) that the case indexes are 1-based, but in fact they are 0-based. Easy one liner solution once that is fixed:

    const serviceLane = (width, cases) => cases.map(curCase => Math.min(...width.slice(curCase[0], curCase[1] + 1)));