Boats for Two — Solution & Editorial
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)
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)