-
Notifications
You must be signed in to change notification settings - Fork 4
[4주차] 백제완 #49
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
Merged
Merged
[4주차] 백제완 #49
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
33dda88
백제완: [CT] 토스트 계란틀_240930
Jewan1120 7e8fb73
백제완: [CT] 토스트 계란틀(코드리뷰 반영)_240930
Jewan1120 dc2152f
백제완: [BOJ] 4386 별자리 만들기_241001
Jewan1120 0d7b2c4
백제완: [SQL] 부모의 형질을 모두 가지는 대장균 찾기_241001
Jewan1120 8f75148
백제완: [BOJ] 4386 별자리 만들기(코드리뷰 반영)_241001
Jewan1120 8280e62
백제완: [BOJ] 7570 줄 세우기_241002
Jewan1120 e1076b2
백제완: [BOJ] 1477 휴게소 세우기_241002
Jewan1120 e987d06
백제완: [PG] 42898 등굣길_241003
Jewan1120 0da6646
백제완: [PG] 42885 구명보트_241004
Jewan1120 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
백제완: [PG] 42885 구명보트_241004
- Loading branch information
commit 0da6646b822eaddee13fb03c7b13a20add985b1c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import java.util.Arrays; | ||
class Solution { | ||
public int solution(int[] people, int limit) { | ||
int answer = 0; | ||
Arrays.sort(people); // 투 포인터를 위한 정렬 | ||
// 그리디한 방식으로 몸무게가 작은 사람 + 큰 사람을 | ||
// 한 보트에 태울 수 있는지 투 포인터로 구현 | ||
int l = 0, r = people.length - 1; | ||
while (l <= r) { | ||
// 작은 사람도 같이 태울 수 있는 지 확인 | ||
if (people[l] + people[r] <= limit) { | ||
l++; | ||
} | ||
r--; | ||
answer++; | ||
} | ||
return answer; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
따로 else문 필요 없이 한번에 증가도 가능하군요...!!
저는 2명 타는 경우랑 1명 타는 경우 이렇게 나눠서 생각 하다보니 else문으로 나눠줬었는데, 불필요한 구현 없이 깔끔한 코드 배워갑니다!👍