Skip to content

Commit

Permalink
2024-11-04
Browse files Browse the repository at this point in the history
  • Loading branch information
jung0115 committed Nov 2, 2024
1 parent f9fbd03 commit 937790b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jung0115/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
| 19차시 | 2024.10.16.수 | 분할정복 | [괄호 변환(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/60058) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/178 |
| 20차시 | 2024.10.19.토 | 백트래킹 | [불량 사용자(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/64064) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/180 |
| 21차시 | 2024.10.23.수 | DFS | [여행경로(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/43164) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/181 |
| 22차시 | 2024.10.30.수 | 브루트포스 | [점 찍기(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/140107) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/182 |
| 22차시 | 2024.10.30.수 | 브루트포스 | [점 찍기(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/140107) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/182 |
| 23차시 | 2024.11.02.토 | 그리디 알고리즘 | [구명보트(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/184 |
21 changes: 21 additions & 0 deletions jung0115/그리디알고리즘/Programmers_42885.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 23차시 2024.11.02.토 : 프로그래머스 - 구명보트(Lv.2)
from collections import deque

def solution(people, limit):
answer = 0
people.sort(reverse = True)
queue = deque(people)

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

if len(queue) > 0 :
answer += 1

return answer

0 comments on commit 937790b

Please sign in to comment.