This is an algorithm that gets events happen to a person in one day; these event aren't necessarily in order. After that it calculates most free time between events.Note that the input format are in 12-hour format and output must be in hh:mm format.
[ '10:00AM-12:30PM',
'02:00PM-02:45PM',
'9:10AM-9:50AM' ]
01:30
- Convert hh:mm format to minute-format: hour * 60 + minutes
- Calculating the difference between the end time of the first event and the start time of the next event
- Keeping the longest time between two events