• + 0 comments

    Java

    Looks Like width array is not provided in the given method signature. Just added that and made appropriate changes to main method.

    public static List<Integer> serviceLane(int n, List<Integer> width, List<List<Integer>> cases) {
        // Write your code here
            List<Integer> s = new ArrayList<>();
            //move through cases
            //get sublist of width
            //add min of sublist to s
            cases.forEach(i -> {
                int start = i.get(0);
                int end = i.get(1) + 1;
                List<Integer> sl = width.subList(start, end);
                int min = Collections.min(sl);
                s.add(min);
            });
            System.out.println(n + " cases: " + cases + " width:" + width) ;
            return s;
        }