Skip to content

Commit 2ec722e

Browse files
committedAug 26, 2021
2021-08-25
1 parent 712c6ce commit 2ec722e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
 

‎0881.救生艇/0881-救生艇.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ def numRescueBoats(self, people, limit):
77
"""
88
people.sort()
99
left, right = 0, len(people) - 1
10-
res = 0
10+
boat_count = 0
1111
while left <= right:
12-
if left == right:
13-
res += 1
14-
break
12+
# print (people[left], people[right], boat_count)
1513
if people[left] + people[right] <= limit:
1614
left += 1
1715
right -= 1
18-
res += 1
1916
else:
2017
right -= 1
21-
res += 1
22-
return res
18+
boat_count += 1
19+
return boat_count

0 commit comments

Comments
 (0)
Please sign in to comment.