Skip to content

Commit

Permalink
2024-11-09
Browse files Browse the repository at this point in the history
  • Loading branch information
jung0115 committed Nov 9, 2024
1 parent 937790b commit b4e98af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion jung0115/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
| 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 |
| 23차시 | 2024.11.02.토 | 그리디 알고리즘 | [구명보트(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/184 |
| 23차시 | 2024.11.02.토 | 그리디 알고리즘 | [구명보트(Lv.2)](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/184 |
| 24처사 | 2024.11.09.토 | 그리디 알고리즘 | [섬 연결하기(Lv.3)](https://school.programmers.co.kr/learn/courses/30/lessons/42861) | https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/187 |
Empty file.
32 changes: 16 additions & 16 deletions jung0115/그리디알고리즘/Programmers_42885.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
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 = 0
people.sort(reverse = True)
queue = deque(people)

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

return answer
else :
queue.popleft()
answer += 1

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

return answer

0 comments on commit b4e98af

Please sign in to comment.