Boats to Save People
mediumMinimum boats to carry people with weight limit
Boats to Save People
Key Insight
Sort people by weight. Pair lightest with heaviest if under limit, otherwise heaviest rides alone.
Step 1Sort Array
Sorted, limit = 3
left
1
02
12
2right
3
3→converge←
Sort people by weight. Limit = 3. Use two pointers at ends.
1 / 5