Skip to content

Commit a2ec0d6

Browse files
committed
meeting-rooms linelint
1 parent bc4ccbb commit a2ec0d6

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

β€Žmeeting-rooms/jdy8739.js

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
import {
2-
Interval,
3-
} from '/opt/node/lib/lintcode/index.js';
4-
2+
Interval,
3+
} from '/opt/node/lib/lintcode/index.js';
4+
5+
/**
6+
* Definition of Interval:
7+
* class Interval {
8+
* constructor(start, end) {
9+
* this.start = start;
10+
* this.end = end;
11+
* }
12+
* }
13+
*/
14+
15+
export class Solution {
516
/**
6-
* Definition of Interval:
7-
* class Interval {
8-
* constructor(start, end) {
9-
* this.start = start;
10-
* this.end = end;
11-
* }
12-
* }
17+
* @param intervals: an array of meeting time intervals
18+
* @return: if a person could attend all meetings
1319
*/
14-
15-
export class Solution {
16-
/**
17-
* @param intervals: an array of meeting time intervals
18-
* @return: if a person could attend all meetings
19-
*/
20-
canAttendMeetings(intervals) {
21-
const sort = intervals.sort((a, b) => {
22-
if (a[1] === b[1]) {
23-
return a[0] - b[0];
24-
}
20+
canAttendMeetings(intervals) {
21+
const sort = intervals.sort((a, b) => {
22+
if (a[1] === b[1]) {
23+
return a[0] - b[0];
24+
}
2525

26-
return a[1] - b[1];
27-
})
28-
29-
for (let i = 0; i < sort.length - 2; i++) {
30-
const current = sort[i][1];
31-
const next = sort[i + 1][0];
26+
return a[1] - b[1];
27+
})
28+
29+
for (let i = 0; i < sort.length - 2; i++) {
30+
const current = sort[i][1];
31+
const next = sort[i + 1][0];
3232

33-
if (current > next) {
34-
return false;
35-
}
33+
if (current > next) {
34+
return false;
3635
}
37-
38-
return true;
3936
}
37+
38+
return true;
4039
}
40+
}
4141

42-
// μ‹œκ°„λ³΅μž‘λ„ O(nlogn) -> sort ν•¨μˆ˜ μ‚¬μš©μœΌλ‘œ μΈν•œ μ‹œκ°„λ³΅μž‘λ„
43-
// κ³΅κ°„λ³΅μž‘λ„ O(1) -> μ‚¬μš©ν•˜λŠ” 자료ꡬ쑰, ν•¨μˆ˜μ‹€ν–‰μŠ€νƒ μ—†μŒ
42+
// μ‹œκ°„λ³΅μž‘λ„ O(nlogn) -> sort ν•¨μˆ˜ μ‚¬μš©μœΌλ‘œ μΈν•œ μ‹œκ°„λ³΅μž‘λ„
43+
// κ³΅κ°„λ³΅μž‘λ„ O(1) -> μ‚¬μš©ν•˜λŠ” 자료ꡬ쑰, ν•¨μˆ˜μ‹€ν–‰μŠ€νƒ μ—†μŒ
4444

45-

0 commit comments

Comments
Β (0)