Skip to content

Commit

Permalink
Merge pull request #14 from AlgoLeadMe/4-kjs254
Browse files Browse the repository at this point in the history
4-kjs254
  • Loading branch information
kjs254 authored Feb 27, 2024
2 parents 9785ac4 + 528bb66 commit dd6a551
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kjs254/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
| 1차시 | 2024.02.12 | 스택 | [기능개발](https://school.programmers.co.kr/learn/courses/30/lessons/42586) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/2) |
| 2차시 | 2024.02.15 || [프로세스](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/6) |
| 3차시 | 2024.02.15 || [야근 지수](https://school.programmers.co.kr/learn/courses/30/lessons/12927) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/10) |
| 4차시 | 2024.02.15 | 그리디 | [구명보트](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/13) |

---
16 changes: 16 additions & 0 deletions kjs254/그리디/구명보트.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections import deque

def solution(people, limit):
answer = 0
people = deque(sorted(people))

while len(people)>1:
if people[0]+people[-1]<=limit:
people.pop()
people.popleft()
answer+=1
else:
people.pop()
answer+=1

return answer+1 if people else answer

0 comments on commit dd6a551

Please sign in to comment.