Greedy Algorithms8 sections · 316 units
Open in Course

Handling Edge Cases

Empty input and ties

Watch out for these edge cases:

1.1. Empty input: : Return 00 (or appropriate default).

2.2. Single interval: : Return 11.

3.3. Ties in end time: : If two activities end at the same time, the order between them does not matter. Both are valid greedy choices.

4.4. Touching intervals: : [1,2][1,2] and [2,3][2,3] do not overlap. They share a point but can both be selected. Always check the problem statement for whether touching intervals overlap. Common bug: using < instead of <= for overlap check.