# ★★☆☆☆ 구명보트
- 난이도 : ★★☆☆☆
- 문제 바로가기 (opens new window)
- 풀이 바로가기 (opens new window)
- 사용 언어 : Java
# 구현코드
import java.util.Arrays;
public class Solution {
public int solution(int[] people, int limit) {
Arrays.sort(people);
int bigPeople = people.length-1;
int smallPeople = 0;
int boatCount = 0;
while (bigPeople >= smallPeople){
boatCount++;
if(people[smallPeople] + people[bigPeople] <= limit){
smallPeople++;
}
bigPeople--;
}
return boatCount;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20