Skip to content

Commit 14da9f6

Browse files
authored
Merge pull request #1292 from AlgorithmWithGod/LiiNi-coder
[20251101] PGM / LV2 / 구명보트 / 이인희
2 parents 5108d1b + d3a178a commit 14da9f6

File tree

1 file changed

+23
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)