Skip to content

Commit 4a6161d

Browse files
committed
87차 2번 문제풀이
1 parent 3a87238 commit 4a6161d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

live8/test87/문제2/이상민.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function solution(people, limit) {
2+
let answer = 0;
3+
let left = 0;
4+
let right = people.length - 1;
5+
people.sort((a, b) => a - b);
6+
7+
while (left <= right) {
8+
if (people[left] + people[right] <= limit) {
9+
left++;
10+
right--;
11+
} else {
12+
right--;
13+
}
14+
answer++;
15+
}
16+
return answer;
17+
}

0 commit comments

Comments
 (0)