Skip to content

Commit 19f78c5

Browse files
authored
Merge pull request #1659 from AlgorithmWithGod/lkhyun
[20251213] PGM / Lv2 / 구명보트 / 이강현
2 parents ce4a003 + f0999b4 commit 19f78c5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```java
2+
import java.util.*;
3+
class Solution {
4+
public int solution(int[] people, int limit) {
5+
int answer = 0;
6+
Arrays.sort(people);
7+
int left = 0;
8+
int right = people.length-1;
9+
10+
while(left <= right){
11+
int rest = limit - people[right--];
12+
answer++;
13+
if(rest >= people[left]){
14+
left++;
15+
}
16+
}
17+
return answer;
18+
}
19+
}
20+
```

0 commit comments

Comments
 (0)