공부기록/프로그래머스
[프로그래머스] 구명보트
메델
2023. 11. 9. 20:11
import java.util.*;
class Solution {
public int solution(int[] people, int limit) {
int answer = 0;
Arrays.sort(people);
int start = 0;
int end = people.length-1;
while(start<= end){
if(people[start]+ people[end]<=limit){
start++;
end--;
}else{
end--;
}
answer++;
}
return answer;
}
}