Why it matters

Interval scheduling teaches greedy vs DP. Understanding shapes technique choice.

Advertisement

The architecture

Unweighted: sort finish + greedy.

Weighted: DP with binary search.

Interval schedulingUnweightedgreedy earliest finishWeightedDP + binary searchChoose methodby variantWeighted uses precomputed next non-conflicting via binary search; O(n log n)
Interval scheduling.
Advertisement

How it works end to end

Weighted DP: dp[i] = max(dp[i-1], v_i + dp[p(i)]) where p(i) = last non-conflicting.

Sort by finish; binary search for p(i).