Skip to content

Commit a040d4f

Browse files
committed
added nonOverlappingIntervals.js
1 parent 77ca7ac commit a040d4f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
2+
3+
4+
5+
// Example 1:
6+
7+
// Input: [[1,2],[2,3],[3,4],[1,3]]
8+
// Output: 1
9+
// Explanation: [1,3] can be removed and the rest of intervals are non-overlapping.
10+
// Example 2:
11+
12+
// Input: [[1,2],[1,2],[1,2]]
13+
// Output: 2
14+
// Explanation: You need to remove two [1,2] to make the rest of intervals non-overlapping.
15+
// Example 3:
16+
17+
// Input: [[1,2],[2,3]]
18+
// Output: 0
19+
// Explanation: You don't need to remove any of the intervals since they're already non-overlapping.
20+
21+
22+
// Note:
23+
24+
// You may assume the interval's end point is always bigger than its start point.
25+
// Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each other.
26+
27+
function eraseOverlapIntervals() {
28+
29+
}

0 commit comments

Comments
 (0)