• + 0 comments

    The problem is incorrect with its parameter, fix it by including width vector in parameter and passing the calculated width vector through main function.

    Problem is insolvable without width so do not waste time figuring alternative.

    Spoiler: Solution in rust:

    fn serviceLane(n: i32, width: &Vec<i32>, cases: &[Vec<i32>]) -> Vec<i32> {
        let mut returnVector: Vec<i32> = Vec::new();
    
        for case in cases {
            let entry: usize = case[0] as usize;
            let exit: usize = case[1] as usize;
    
            let mut minimum = width[entry];
            for index in entry + 1..=exit {
                if width[index] < minimum {
                    minimum = width[index];
                }
            }
    
            returnVector.push(minimum);
        }
    
        returnVector
    }