Solution: Boats to Save People
Explore how the greedy pattern can optimize evacuation problems by pairing the heaviest and lightest persons within weight limits to minimize the number of boats used. Understand sorting and two-pointer techniques to implement an efficient solution for rescuing people with weight restrictions.
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 ...