Skip to content

Commit

Permalink
#7 22.11.05 > 회의실 배정
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Nov 5, 2022
1 parent ab2b267 commit 5f22ce7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/inf/sort,greedy/8_rere.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

function solution(arr) {
let answer = [];

arr.sort((a, b) => {
if (a[1] === b[1]) {
return a[0] - b[0];
} else {
return a[1] - b[1];
}
});

let endTime = 0;
for (let x of arr) {
if (x[0] >= endTime) {
answer.push(x);
endTime = x[1];
}
}
return answer.length;
}

let arr = [
[1, 4],
[2, 3],
[3, 5],
[4, 6],
[5, 7],
];
console.log(solution(arr));
2 changes: 1 addition & 1 deletion src/inf/sort,greedy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| 5 | 몰라몰라몰라 | |
| 6 | O | 22.11.01 |
| 7 || 22.11.01 |
| 8 || O |
| 8 || 22.11.05 |
| 9 || O |
| 10 || O |
| 11 | X | O |
Expand Down

0 comments on commit 5f22ce7

Please sign in to comment.