We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8d452b commit 599a7d8Copy full SHA for 599a7d8
meeting-rooms/gitsunmin.ts
@@ -0,0 +1,26 @@
1
+/**
2
+ * https://www.lintcode.com/problem/920/
3
+ * time complexity : O(n log n)
4
+ * space complexity : O(log n)
5
+ */
6
+
7
+export class Interval {
8
+ start: number;
9
+ end: number;
10
+ constructor(start: number, end: number) {
11
+ this.start = start;
12
+ this.end = end;
13
+ }
14
+}
15
+g
16
+export function canAttendMeetings(intervals: Interval[]): boolean {
17
+ intervals.sort((a, b) => a.start - b.start);
18
19
+ for (let i = 0; i < intervals.length - 1; i++) {
20
+ const { end } = intervals[i];
21
+ const { start: nextStart } = intervals[i + 1];
22
23
+ if (end > nextStart) return false;
24
25
+ return true;
26
0 commit comments