Greedy Algorithms8 sections · 316 units
Open in Course

Tandem Bicycle - Maximize Speed

Pair fast with slow

To maximize total speed: Pair the fastest red with the slowest blue, second fastest red with second slowest blue, and so on.

Why? If two fast riders are paired, one's speed is "wasted" (only the faster one counts). By pairing fast with slow, you use every fast rider's speed.

Example: red = [5, 3, 1], blue = [4, 2, 0]. Pair: (5,0), (3,2), (1,4). Speeds: 55, 33, 44. Total: 1212. This ensures no fast rider is hidden behind another fast rider. Sort one array ascending, the other descending.