class Solution:
def numRescueBoats(self, people: List[int], limit: int) -> int:
if people is None:
return 0
people.sort()
light = 0
heavy = len(people) - 1
result = 0
while light <= heavy:
if people[light] + people[heavy] <= limit:
light = light + 1
heavy = heavy - 1
result += 1
return result
#贪心算法的应用,考虑体重最轻的人和体重最重的人能否乘坐同一条船
#可以的话就乘坐,不可以的话就由重的人单独乘船。