# Untitled

unknown
c_cpp
2 months ago
1.7 kB
1
Indexable
Never
```/*

Given a list of meetings (start time, end time, and number of attendees),
determine the interval of time where the most number of people are busy in meetings.
(Include that number of people as well).

Timestamps: floating point representation (Unix timestamp, etc.)

9:00-10:00  -> 5
9:30-10:30  -> 6
10:15-11:15 -> 7

10:15-10:30 -> 13
(start: 10:15, end: 10:30, number: 13)

9:00-10:00  -> 5
9:30-10:00  -> 6
10:15-11:15 -> 7

example:

1) 9- 9:50.. -> 5
2) 9:30-10 .. -> 6
2) 10:15 .. -> 7

1. created sorted time intervals based on start time
2.  merge two intervals into nonoverlapping intervals
first interval [min(start1,start2), min(end1,end2), per1]
second [max(start1,start2), min(end1, end2) ,per1 + per2]
thrid  [min(end1, end2), max(end1, end2), per2]
3.  do a linear scan of merged time intervals

9  9:30  10:00  10:15
[  5 ]
[  6  ]
[  7           ]
->      [   7       ]
[9  ]
-----------------------
[  5 ]
[13]
[   20...]
[ 29..]
9:45-10:15 -> 14

10:15-11:15 -> 7

(start: 10:15, end: 11:15, number: 7)

======================
9     9:30      10:00          10:30         11:00
[       5       ]
[         10            ]
[         6         ]
[   7   ]
-------------------------------------
[   5   ]
[  15   ]
[    10][ 16 ]
[  6  ][..13   ][ 7  ]
*/

#include <iostream>
using namespace std;

// To execute C++, please define "int main()"
int main() {
auto words = { "Hello, ", "World!", "\n" };
for (const char* const& word : words) {
cout << word;
}
return 0;
}
```