• + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/iuLCUdG77yQ You will need to update the serviLane function by adding the width vector, since it was forgotten.

    vector<int> serviceLane(int n, vector<vector<int>> cases, vector<int> width) {
        vector<int> result;
        for(auto cas: cases){
            int r = width[cas[0]];
            for(int i = cas[0]; i <= cas[1]; i++){
                r = min(r, width[i]);
            }
            result.push_back(r);
        }
        return result;
    }