-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use strict"; | ||
|
||
function solution(arr) { | ||
let answer = 0; | ||
let timeTable = []; | ||
for (let [come, out] of arr) { | ||
timeTable.push([come, "c"]); | ||
timeTable.push([out, "o"]); | ||
} | ||
|
||
timeTable.sort((a, b) => { | ||
if (a[0] === b[0]) return b[1] - a[1]; // 만약 시간이 같으면, out -> come 순으로 정렬 | ||
return a[0] - b[0]; | ||
}); | ||
|
||
let people = 0; | ||
for (let [time, status] of timeTable) { | ||
if (status === "c") people++; | ||
else people--; | ||
answer = Math.max(people, answer); | ||
} | ||
return answer; | ||
} | ||
|
||
let arr = [ | ||
[14, 18], | ||
[12, 16], | ||
[15, 20], | ||
[20, 30], | ||
[5, 15], | ||
]; | ||
console.log(solution(arr)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters