-
Notifications
You must be signed in to change notification settings - Fork 0
[오늘의 알고리즘] 구명보트 #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[오늘의 알고리즘] 구명보트 #63
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||
| from collections import deque | ||||||||
|
|
||||||||
| def solution(people, limit): | ||||||||
| people.sort() | ||||||||
|
|
||||||||
| queue = deque(people) | ||||||||
| count = 0 | ||||||||
| boat = [] | ||||||||
|
|
||||||||
| while queue: | ||||||||
| person = queue.popleft() | ||||||||
| if sum(boat) + person <= limit and len(boat) <= 2: | ||||||||
|
||||||||
| if sum(boat) + person <= limit and len(boat) <= 2: | |
| if sum(boat) + person <= limit and len(boat) < 2: |
Copilot
AI
Apr 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the else branch, the current person is skipped and not reprocessed, which may result in an undercount of boats. Consider re-adding the current person back to the queue or re-evaluating without discarding this person.
| else: | |
| else: | |
| queue.appendleft(person) |
Uh oh!
There was an error while loading. Please reload this page.