711. Boats to Save People
Given an array of people's weights and a limit for each boat, determine the minimum number of boats required to carry all the people. Each boat can carry a maximum weight equal to the limit and can accommodate at most two people whose combined weight does not exceed the limit.
The input starts with an integer N, denoting the size of the array. The next line contains N space-separated integers representing the weights of the people. Finally, a single integer is provided as the limit.
The output is a single integer representing the minimum number of boats required to carry all the people.
4 3 5 3 4 5
- 1 <= people.length <= 5 * 104 - 1 <= people[i] <= limit <= 3 * 104