Activity Selection

The classic greedy problem. Select the maximum number of non-overlapping activities by deadline.

43 lessons
117 min
Codeforces: 900-1500LeetCode: 1400-1700

Lessons

1. Intro

The gateway problem

2m

2. Problem - Activity Selection

The classic setup

3m1 problems

3. Trying the Example

Finding the answer

3m

4. Wrong Approach 1 - Earliest Start

Why it fails

3m

5. Wrong Approach 2 - Shortest Duration

Why it fails

3m

6. Wrong Approach 3 - Fewest Conflicts

Why it fails

3m

7. The Correct Approach

Earliest end time

3m

8. Quiz: Sort Order

Test your understanding

1m1 problems

9. The Algorithm

Step by step

3m

10. Walkthrough

Tracing the algorithm

4m

11. Implementation

The code

3m1 problems

12. Proof Overview

Why it is optimal

2m

13. Proof Step 1 - First Activity

The greedy choice

4m

14. Proof Step 2 - Induction

Extending the argument

3m

15. Proof Step 3 - Conclusion

G is optimal

3m

16. Quiz: Exchange Argument

Test your understanding

1m1 problems

17. Lessons from Activity Selection

Key patterns

3m

18. Problem - N Meetings in One Room

Same problem, different story

3m1 problems

19. Problem - Non-overlapping Intervals

Minimum removals

3m1 problems

20. Non-overlapping - Walkthrough

Tracing the algorithm

3m

21. Non-overlapping - Implementation

The code

3m1 problems

22. Quiz: Problem Transformation

Recognize equivalence

1m1 problems

23. Problem - Minimum Arrows

Burst balloons

3m1 problems

24. Minimum Arrows - The Idea

Grouping overlapping balloons

3m

25. Minimum Arrows - Algorithm

Sort and shoot

3m

26. Minimum Arrows - Walkthrough

Tracing the algorithm

3m

27. Minimum Arrows - Implementation

The code

3m1 problems

28. Comparing the Three Problems

Same pattern, different questions

3m

29. Handling Edge Cases

Empty input and ties

3m

30. Quiz: Edge Cases

Touching intervals

1m1 problems

31. Variant - Weighted Activity Selection

When greedy fails

3m

32. Why Weighted Needs DP

A counterexample

3m

33. Problem - Meeting Rooms I

Can attend all?

3m1 problems

34. Meeting Rooms I - Algorithm

Simple overlap check

3m1 problems

35. Problem - Meeting Rooms II

Minimum rooms needed

3m1 problems

36. Meeting Rooms II - Approach 1

Event-based counting

3m

37. Meeting Rooms II - Walkthrough

Tracing the events

3m

38. Meeting Rooms II - Approach 2

Min-heap method

3m

39. Meeting Rooms II - Implementation

The code

3m1 problems

40. Quiz: Meeting Rooms II

Apply the algorithm

1m1 problems

41. Activity Selection vs Meeting Rooms

Different questions

3m

42. What is Next

Looking ahead

2m

43. Section Recap

What we learned

2m

Practice Problems

1.
Unique Numbercodeforces
2.
3.
4.
5.
Coin Rowscodeforces

Ready to start learning?

Access all 43 lessons with interactive content and progress tracking.