Skip to content

Commit

Permalink
#7 22.03.05 > 9번문제 풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Mar 5, 2022
1 parent 2de4b7e commit c0a791e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
39 changes: 39 additions & 0 deletions src/inf/sort,greedy/9.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<meta charset="UTF-8">
<title>출력결과</title>
</head>
<body>
<script>
function solution(times){
let answer=0;
let T_line=[];
for(let x of times){
T_line.push([x[0], 'start']);
T_line.push([x[1], 'end']);
}
console.log(...T_line);
T_line.sort((a,b) => {
if(a[0]===b[0]) {
return a[1].charCodeAt()-b[1].charCodeAt();
} else {
return a[0]-b[0];
}
});
let count = 0;
for(let x of T_line) {
if(x[1]==='start') {
count++;
} else {
count--;
}
answer = Math.max(answer,count);
}
return answer;
}

let arr=[[14, 18], [12, 15], [15, 20], [20, 30], [5, 14]];
console.log(solution(arr));
</script>
</body>
</html>
10 changes: 5 additions & 5 deletions src/inf/sort,greedy/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# List
|번호|정답여부|풀이|
|:---:|:---:|:---:|
|번호|정답여부|풀이|개념|
|:---:|:---:|:---:|:---:|
|1||예정|
|2||예정|
|3|O||
|4|O||
|5|||
|6|||
|7|||
|8|||
|9|||
|7|X||Array.sort()
|8|X||
|9|X||
|10|||
|11|||
|12|||
Expand Down

0 comments on commit c0a791e

Please sign in to comment.