+1 vote
Suppose you are given a list of lectures with there start time and end times. How can you choose the maximum number of non-overlapping lectures?
in Greedy Algorithms by AlgoMeister (684 points)

2 Answers

0 votes
  1. Sort by end times
  2. Take the lecture that ends first.
  3. Remove all lectures that conflict (overlap) with it.
  4. Then, start again (recurse)

by AlgoMeister (1.6k points)
0 votes

Sort the given intervals based on their end times. This is crucial to ensure that you are considering intervals that end earliest first. Start with the first interval and consider it as part of the solution. Iterate through the sorted intervals.

For each interval, check if its start time is greater than or equal to the end time of the last selected interval. If it is, add it to the solution. Maintain a count of the selected intervals. The count represents the maximum number of non-overlapping intervals.

by (212 points)

Related questions

0 votes
4 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
0 votes
3 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
+1 vote
2 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
+1 vote
2 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
0 votes
2 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
The Book: Analysis and Design of Algorithms | Presentations on Slideshare | Lecture Notes, etc
...