'''
  https://leetcode.com/problems/boats-to-save-people/
'''


class Solution:
    def numRescueBoats(self, people: List[int], limit: int) -> int:
        people.sort()

        i, j = 0, len(people)-1
        output = 0

        while (i <= j):
            output += 1
            if people[i]+people[j] <= limit:
                i += 1
            j -= 1

        return output

bdbce2a67d7c89db1152031e8ec70e0263379007
<mask token>

<mask token>


class Solution:
    <mask token>

<mask token>


class Solution:

    def numRescueBoats(self, people: List[int], limit: int) ->int:
        people.sort()
        i, j = 0, len(people) - 1
        output = 0
        while i <= j:
            output += 1
            if people[i] + people[j] <= limit:
                i += 1
            j -= 1
        return output

'''
  https://leetcode.com/problems/boats-to-save-people/
'''


class Solution:
    def numRescueBoats(self, people: List[int], limit: int) -> int:
        people.sort()

        i, j = 0, len(people)-1
        output = 0

        while (i <= j):
            output += 1
            if people[i]+people[j] <= limit:
                i += 1
            j -= 1

        return output
