Sort by

recency

|

1326 Discussions

|

  • + 0 comments

    n should be replaced with width. then:

    def serviceLane(width, cases): return [min(width[c[0]:c[1]+1]) for c in cases]

  • + 0 comments

    I think the actual puzzle is fixing the code :)

    public static List<Integer> serviceLane(int n, List<Integer> widths, List<List<Integer>> cases) {
        List<Integer> result = new LinkedList<>();
        for(List<Integer> _case:cases) {
            int start = _case.get(0);
            int end = _case.get(_case.size()-1);
    
            int min = widths.subList(start, end+1).stream().min(Integer::compare).get();
            result.add(min);
        }
        return result;
    }
    
  • + 0 comments

    Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-service-lane-problem-solution.html

  • + 0 comments

    there is no width array being passed, you can not complete this one

  • + 4 comments

    the problem suck,

    1.you need change the function prototype as; vector serviceLane(vector> cases, vector width) it mean that you need read the main() Legal fuction.

    check from the problme description, you will think that {enter,exit} in the case is the index starting from 1, but acutally you need change it to as starting from 0 then pass.