/******************************************************************************

                              Online C++ Debugger.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Debug" button to debug it.

*******************************************************************************/

#include <iostream>
#include <algorithm>
#include <vector>


using namespace std;

/*
get minimum time, get maximum time
create an array list of size max - min, ledger
iterate throgh times
	iterate from times[0] to times[1]
		ledger[i] ++
		
get max from ledger
return ledgermax
*/

bool cmpMin(const vector<int> &a, const vector<int> &b) {
	  return a[0] < b[0];
}

bool cmpMax(const vector<int> &a, const vector<int> &b) {
	return a[1] > b[1];
}

int laptopRentals(vector<vector<int>> times) {
  int min = (*min_element(times.begin(), times.end(), cmpMin))[0];
	int max = (*max_element(times.begin(), times.end(), cmpMax))[1];
	
	cout << "min " << min << endl;
	cout << "max " << max << endl;
	
	int ledger[max - min] = {0};
	cout << endl;
	for(int i = 0; i < times.size(); i++) {
		for(int j = times[i][0]; j < times[i][1]; j++) {
			ledger[j - min] ++;
			for(int k = 0; k < max - min; k ++) {
			  cout << k + min << ":" << ledger[k] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return *max_element(ledger, ledger + max - min);
}

int main()
{
    vector<vector<int>> times = {{0, 2}, {1, 4}, {4, 6}, {0, 4}, {7, 8}, {9, 11}, {3, 10}};
    cout<<laptopRentals(times);

    return 0;
}
 
by