230701 구명보트

Jongleee·2023년 7월 1일
0

TIL

목록 보기
300/576
public int solution(int[] people, int limit) {
	Arrays.sort(people);

	int answer = 0;
	int min = 0;
	int max = people.length - 1;

	while (min <= max) {
		if (people[min] + people[max] <= limit) {
			min++;
		}
		max--;
		answer++;
	}

	return answer;
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/42885

0개의 댓글