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 87e4857 commit 89b4732Copy full SHA for 89b4732
1288. 删除被覆盖区间.js
@@ -0,0 +1,27 @@
1
+/**
2
+ * @param {number[][]} intervals
3
+ * @return {number}
4
+ */
5
+var removeCoveredIntervals = function (intervals) {
6
+ intervals.sort((a, b) => {
7
+ if (a[0] != b[0]) {
8
+ return a[0] - b[0];
9
+ } else {
10
+ return b[1] - a[1];
11
+ }
12
+ });
13
+
14
+ const result = [];
15
+ for (const current of intervals) {
16
+ if (result.length === 0) {
17
+ result.push(current);
18
19
+ const last = result[result.length - 1];
20
+ if (!(current[0] >= last[0] && current[1] <= last[1])) {
21
22
23
24
25
26
+ return result.length;
27
+};
0 commit comments