mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个二维整数数组 <code>intervals</code> ,其中 <code>intervals[i] = [left<sub>i</sub>, right<sub>i</sub>]</code> 表示 <strong>闭</strong> 区间 <code>[left<sub>i</sub>, right<sub>i</sub>]</code> 。</p>
 | 
						||
 | 
						||
<p>你需要将 <code>intervals</code> 划分为一个或者多个区间 <strong>组</strong> ,每个区间 <b>只</b> 属于一个组,且同一个组中任意两个区间 <strong>不相交</strong> 。</p>
 | 
						||
 | 
						||
<p>请你返回 <strong>最少</strong> 需要划分成多少个组。</p>
 | 
						||
 | 
						||
<p>如果两个区间覆盖的范围有重叠(即至少有一个公共数字),那么我们称这两个区间是 <strong>相交</strong> 的。比方说区间 <code>[1, 5]</code> 和 <code>[5, 8]</code> 相交。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<b>输入:</b>intervals = [[5,10],[6,8],[1,5],[2,3],[1,10]]
 | 
						||
<b>输出:</b>3
 | 
						||
<b>解释:</b>我们可以将区间划分为如下的区间组:
 | 
						||
- 第 1 组:[1, 5] ,[6, 8] 。
 | 
						||
- 第 2 组:[2, 3] ,[5, 10] 。
 | 
						||
- 第 3 组:[1, 10] 。
 | 
						||
可以证明无法将区间划分为少于 3 个组。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<b>输入:</b>intervals = [[1,3],[5,6],[8,10],[11,13]]
 | 
						||
<b>输出:</b>1
 | 
						||
<b>解释:</b>所有区间互不相交,所以我们可以把它们全部放在一个组内。</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= intervals.length <= 10<sup>5</sup></code></li>
 | 
						||
	<li><code>intervals[i].length == 2</code></li>
 | 
						||
	<li><code>1 <= left<sub>i</sub> <= right<sub>i</sub> <= 10<sup>6</sup></code></li>
 | 
						||
</ul>
 |