Index

Module 08 · DSAWorked problems, in English

Clinic #29: Non-overlapping Intervals

Algorithm Design Patterns
Algorithm Design Patterns · Open board

A catalogue of ways to attack a problem. Its greedy panel says the rule out loud: take the locally best choice, never look back, and prove the choice safe. This clinic is that proof, done once by hand on a real problem.

Before you start. Clinic #28: Merge Intervals took a pile of road closures, sorted them by where they start, and walked the road once, widening one sign at a time; if you have not read it, the one thing to carry over is that an interval is a start and an end, like “km 2 to km 6”. Sorting costs a little more than one pass, written O(n log n), and trying every subset of n things costs O(2ⁿ), which doubles with each item you add; Sorting & Searching shows where the first one comes from.

Continue reading with a plan

The first three lessons of every track are free. This lesson is included with a plan, which unlocks every lesson, board, video, lab and paper for one price.

View plans →Already a member? Sign in

Lab

Grabbing the biggest coin that fits gives the fewest coins with 1, 5, 10 and 25. Does it with any coins?

Pick 1, 3, 4 under The coins, set The amount to make to 6, and watch Coins greedy wasted.

Open The greedy bet →

Review DSA →

Saved in this browser, and to your account when you sign in.