Determine the busiest day from a list of dates.

87 Views Asked by At

There are N date ranges which include check-in date and check-out date. How can I find out the busiest day?

Example:

2016-10-12 to 2016-10-18
2016-10-11 to 2016-10-15
2016-10-13 to 2016-10-14
2016-10-12 to 2016-10-13

From these dates, it is obvious that 2016-10-12 was booked on all 4 times. How can I mathematically solve this?

Using two dates we can find out overlaps like this.

1

There are 1 best solutions below

1
On

Hint -

I think you can create 4 sets for given 4 date range's. Then you can find intersection of these 4 sets.