Skip to content

Commit ee18212

Browse files
author
Eric
committed
93차 3번 문제풀이
1 parent 89ae20b commit ee18212

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

live9/test93/문제3/황장현.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function solution(routes) {
2+
routes.sort((a, b) => a[1] - b[1]);
3+
4+
let cameraCount = 0;
5+
let lastCameraPos = -30001;
6+
7+
for (let route of routes) {
8+
let [enter, exit] = route;
9+
10+
if (enter > lastCameraPos) {
11+
cameraCount++;
12+
lastCameraPos = exit;
13+
}
14+
}
15+
16+
return cameraCount;
17+
}
18+
19+
console.log(
20+
solution([
21+
[-20, -15],
22+
[-14, -5],
23+
[-18, -13],
24+
[-5, -3],
25+
])
26+
);

0 commit comments

Comments
 (0)