Problems > Boats for Two > Editorial

Boats for Two — Solution & Editorial

Back to the Problem

Sort; pair the heaviest person with the lightest if they fit, otherwise the heaviest rides alone. Two pointers moving inward.

Complexity: O(N log N)