import java.util.*;
class Solution {
public int solution(int[] people, int limit) {
Arrays.sort(people);
int left = 0; // 가장 가벼운 사람
int right = people.length - 1; // 가장 무거운 사람
int answer = 0;
while(left <= right) {
if(people[left] + people[right] <= limit) {
left++;
}
right--;
answer++;
}
return answer;
}
}
투포인터를 이용해 턴 마다 가장 무거운 사람을 무조건 태워 보내야 한다는 개념으로 코드 설계