Skip to content

Commit d3a178a

Browse files
authored
[20251101] PGM / LV2 / 구명보트 / 이인희
1 parent a0ef929 commit d3a178a

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)