Boats to Save People
Medium · Greedy · about 15 minutes
Asked at Amazon, Google, Bloomberg, Meta.
Person i weighs people[i], and nobody weighs more than limit. A boat takes one or two people as long as their combined weight is at most limit. What is the smallest number of boats that gets everyone across?