Greedy Algorithms8 sections · 316 units
Open in Course

Tandem Bicycle - Minimize Speed

Pair fast with fast

To minimize total speed: Pair riders with similar speeds. Sort both arrays ascending and match by position.

Why? When two fast riders are paired, only one counts (the faster). You "hide" one fast rider's speed behind another.

Example: red = [5, 3, 1], blue = [4, 2, 0]. Pair: (1,0), (3,2), (5,4). Speeds: 11, 33, 55. Total: 99. This approach wastes as many fast riders as possible by pairing them together. Sort both arrays the same direction and match positions.