HackerRank 'Service Lane' Solution

by Srikant Padala on June 25, 2016, 4:42 am


Find the minimum width between each interval (both left and right inclusive); this will be the maximum width vehicle that can go. 

Service Lane Problem Statement


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int t;
    cin >> n >> t;
    vector<int> width(n);
    for(int width_i = 0;width_i < n;width_i++){
       cin >> width[width_i];
    for(int a0 = 0; a0 < t; a0++){
        int i;
        int j;
        cin >> i >> j;
        cout << *min_element(width.begin()+i, width.begin()+j+1) << endl;
    return 0;

Coming Soon.