Skip to content

[PGS[구명보트 - #91

Open
yangyeeeun wants to merge 1 commit into
mainfrom
yee/lifeboat
Open

[PGS[구명보트#91
yangyeeeun wants to merge 1 commit into
mainfrom
yee/lifeboat

Conversation

@yangyeeeun

Copy link
Copy Markdown
Collaborator

🍪 문제 이름

Resolve: 구명보트


🍊 문제 정의

| people | limit | return |
|---------------- -|------|--------|
| [70, 50, 80, 50] | 100 | 3 |
| [70, 80, 50] | 100 | 3 |


🍑 알고리즘 설계

풀이 과정에서 본인이 생각한 내용을 작성해 주세요.
inr배열을 deque로 새로 만들고 정렬을 했습니다. 왜냐하면 가장 최선은 작은수와 큰수의 합이기 때문에 deque의 앞과 뒤에서 숫자를 꺼내면 자연스럽게 될 수 있습니다.

# 특히 리뷰받고 싶은 코드 일부를 여기에 작성해 주세요.

while(!p_list.isEmpty()){
if(p_list.size()==1){
p_list.pollFirst();
count++;
break;
}
int small = p_list.peekFirst();
int big = p_list.peekLast();
if(small+ big > limit){
p_list.pollLast();
}else{
p_list.pollFirst();
p_list.pollLast();
}
count++;
}

🥝 최악 수행 시간 복잡도

  • O()

🍰 특이 사항 (Optional)

참고 자료나 추가로 설명하고 싶은 내용을 작성해 주세요.

@yangyeeeun yangyeeeun self-assigned this Jul 17, 2026
@yangyeeeun yangyeeeun linked an issue Jul 17, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PGS] 구명보트 / level2

1 participant