mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given an array of intervals <code>intervals</code> where <code>intervals[i] = [start<sub>i</sub>, end<sub>i</sub>]</code>, return <em>the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping</em>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> intervals = [[1,2],[2,3],[3,4],[1,3]]
 | 
						|
<strong>Output:</strong> 1
 | 
						|
<strong>Explanation:</strong> [1,3] can be removed and the rest of the intervals are non-overlapping.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> intervals = [[1,2],[1,2],[1,2]]
 | 
						|
<strong>Output:</strong> 2
 | 
						|
<strong>Explanation:</strong> You need to remove two [1,2] to make the rest of the intervals non-overlapping.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 3:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> intervals = [[1,2],[2,3]]
 | 
						|
<strong>Output:</strong> 0
 | 
						|
<strong>Explanation:</strong> You don't need to remove any of the intervals since they're already non-overlapping.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= intervals.length <= 10<sup>5</sup></code></li>
 | 
						|
	<li><code>intervals[i].length == 2</code></li>
 | 
						|
	<li><code>-5 * 10<sup>4</sup> <= start<sub>i</sub> < end<sub>i</sub> <= 5 * 10<sup>4</sup></code></li>
 | 
						|
</ul>
 |