# ★★☆☆☆ 구명보트

# 구현코드

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