Skip to content

Instantly share code, notes, and snippets.

@Desolve
Last active January 13, 2021 13:26
Show Gist options
  • Save Desolve/c315324b270acabd8a584d6b8554adf8 to your computer and use it in GitHub Desktop.
Save Desolve/c315324b270acabd8a584d6b8554adf8 to your computer and use it in GitHub Desktop.
0881 Boats to Save People
class Solution:
def numRescueBoats(self, people: List[int], limit: int) -> int:
people.sort()
l, r = 0, len(people) - 1
res = 0
while l <= r:
if people[l] + people[r] <= limit: l += 1
r -= 1
res += 1
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment