Someone asked me this question:
You are given a list of intervals. You have to design an algorithm to find the sequence of non-overlapping intervals so that the sum of the range of intervals is maximum.
For Example:
If given intervals are:
["06:00","08:30"],
["09:00","11:00"],
["08:00","09:00"],
["09:00","11:30"],
["10:30","14:00"],
["12:00","14:00"]
Range is maximized when three intervals
[“06:00”, “08:30”],
[“09:00”, “11:30”],
[“12:00”, “14:00”],
are chosen.
Therefore, the answer is 420 (minutes).