• + 0 comments

    My Simple Solution in Java, You need to pass the width as an function argument with its type (Here it is List of type integer). You need to modified function as follow:

    public static List<Integer> serviceLane(List<Integer> width, List<List<Integer>> cases) {
        ArrayList <Integer> widest = new ArrayList <Integer>();
        int arr [] = new int [2];
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < cases.size() ; i++){
            for(int j = 0; j < cases.get(i).size(); j++){
                arr[j] = cases.get(i).get(j);
            }
            for(int k = arr[0]; k <= arr[1]; k++){
                if(width.get(k) < min){
                    min = width.get(k);
                }
            }
            widest.add(min);
            min = Integer.MAX_VALUE;
        }    
        return widest;
        }
    }