Approach Summary
Sort, then greedily pair heaviest with lightest if they fit together; otherwise send heaviest alone.
How to Recognize This Pattern
- Pair lightest + heaviest together if weight allows
- Greedy: always try to fill each boat
Complexity Analysis
Time Complexity
O(n log n)
Space Complexity
O(1)
Tags
Array Two Pointers Greedy Sorting