Solution: Boats to Save People
Understand how to apply the greedy algorithm to minimize the number of boats needed to save people given weight limits and pair constraints. Learn to sort, use two pointers, and efficiently decide on pairing or single rescue, optimizing time and space complexity.
Statement
A big ship with numerous passengers is sinking, and there is a need to evacuate these people with the minimum number of life-saving boats. Each boat can carry, at most, two persons however, the weight of the people cannot exceed the carrying weight limit of the boat.
We are given an array, people, where people[i] is the weight of the ...