This means 3 people entered the building. An exit looks like this:
1
{"timestamp": 1526580382, count:2,"type": "exit"}
This means that 2 people exited the building. timestamp is in Unix time.
Find the busiest period in the building, that is, the time with the most people in the building. Return it as a pair of (start, end) timestamps. You can assume the building always starts off and ends up empty, i.e. with 0 people inside.
Input: [{"timestamp":1526579928,"count":3,"type":"enter"},{"timestamp":1526580382,"count":2,"type":"exit"},{"timestamp":1526580482,"count":5,"type":"enter"},{"timestamp":1526581482,"count":4,"type":"exit"}]Output: (1526580482,1526581482)Explanation: The building is busiest between timestamp 1526580482 and 1526581482with6 people inside.
Input: [{"timestamp":1526572561,"count":5,"type":"enter"},{"timestamp":1526575342,"count":2,"type":"exit"},{"timestamp":1526578721,"count":8,"type":"enter"},{"timestamp":1526582458,"count":1,"type":"exit"},{"timestamp":1526587392,"count":9,"type":"enter"}]Output: (1526578721,1526582458)Explanation: The building is busiest between timestamp 1526578721 and 1526582458with11 people inside.
We can process the data entries in order of their timestamps and keep track of the number of people inside the building. By maintaining these counts, we can determine the period during which the count is at its highest.