In this

**HackerEarth Minimum Cabs, problem solution**Assume there are N persons and each person needs exactly one cab. For each person, you are given the start time and end time (both inclusive) during which that person will travel. Find the minimum number of cabs required.## HackerEarth Minimum Cabs problem solution.

`#include <bits/stdc++.h>`

using namespace std;

const int MAX = 1500;

int A[MAX];

int main(int argc, char* argv[])

{

if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);

if(argc == 3) freopen(argv[2], "w", stdout);

ios::sync_with_stdio(false);

int n, hh1, hh2, mm1, mm2, smins, emins, ans;

cin >> n;

for (int i = 0; i < n; i++) {

cin >> hh1 >> mm1 >> hh2 >> mm2;

smins = hh1 * 60 + mm1;

emins = hh2 * 60 + mm2;

A[smins]++;

A[emins+1]--;

}

ans = A[0];

for (int i = 1; i < MAX; i++) {

A[i] += A[i-1];

ans = max(ans, A[i]);

}

cout << ans << endl;

return 0;

}

## 0 Comments