Solution: Boats to Save People
Discover how to apply the greedy pattern to solve the problem of rescuing people with the minimum number of boats. Learn to pair the heaviest and lightest individuals efficiently, understand the sorting and two-pointer technique, and analyze the time and space complexity involved in optimizing the rescue process.
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 ...