当前位置:网站首页>不会就坚持69天吧 合并区间
不会就坚持69天吧 合并区间
2022-07-29 04:13:00 【一只小小明】

class Solution {
public int[][] merge(int[][] intervals) {
if (intervals.length == 0) {
return new int[0][2];
}
Arrays.sort(intervals, new Comparator<int[]>() {
public int compare(int[] interval1, int[] interval2) {
return interval1[0] - interval2[0];
}
});
List<int[]> merged = new ArrayList<int[]>();
for (int i = 0; i < intervals.length; ++i) {
int L = intervals[i][0], R = intervals[i][1];
if (merged.size() == 0 || merged.get(merged.size() - 1)[1] < L) {
merged.add(new int[]{L, R});
} else {
merged.get(merged.size() - 1)[1] = Math.max(merged.get(merged.size() - 1)[1], R);
}
}
return merged.toArray(new int[merged.size()][]);
}
}
作者:LeetCode-Solution
链接:https://leetcode.cn/problems/SsGoHC/solution/he-bing-qu-jian-by-leetcode-solution-ghjl/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。边栏推荐
- Codeforces round 810 (Div. 2) d. rain (segment tree difference)
- Whole house WiFi solution: mesh router networking and ac+ap
- 当我从数据库获取到了winfrom特定的控件ID之后我需要通过这个ID找到对应的控件,并对控件的TEXT文本进行赋值这该怎么做
- Openfeign asynchronous call problem
- There is a special cryptology language called asn.1
- AssertionError(“Torch not compiled with CUDA enabled“)
- Shielding ODBC load balancing mode in gbase 8A special scenarios?
- SQL time fuzzy query datediff() function
- When defining an array, the size must be constant
- 基于STM32和阿里云的环境检测系统设计
猜你喜欢

通过js来实现一元二次方程的效果,输入a,b,c系数后可计算出x1和x2的值

为什么opengauss启动的时候这么多的unknown?

RMAN do not mark expired backups

Why are there so many unknowns when opengauss starts?

Zhihuijun, a genius of Huawei, made a modular mechanical keyboard, which caused an earthquake in the geek circle. Netizens: This is the real customization
![[paper translation] vectornet: encoding HD maps and agent dynamics from vectorized representation](/img/4b/150689d5e4809ae66a4297915ecd0c.png)
[paper translation] vectornet: encoding HD maps and agent dynamics from vectorized representation

C language to achieve three chess game (detailed explanation)

STM32F103ZET6程序移植为C8T6+C8T6下载程序flash timeout的解决方案

Some problems about pointers

C语言实现三子棋游戏(详解)
随机推荐
How to write the filter conditions of data integration and what syntax to use? SQL syntax processing bizdate can not be
Asp. Net MVC, how can the controller in the folder jump to the controller in the root directory?
Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
SVG--loading动画
MySQL gets the maximum value record by field grouping
基于STM32和阿里云的环境检测系统设计
opengauss预检查安装
Is the browser multi process or single process?
The solution of porting stm32f103zet6 program to c8t6+c8t6 download program flash timeout
Copy products with one click from Taobao, tmall, 1688, wechat, jd.com, Suning, taote and other platforms to pinduoduo platform (batch upload baby details Interface tutorial)
Problems encountered in vscode connection SSH
rman不标记过期备份
Fu Yingna: Yuan universe is the new generation of Internet!
Codeforces round 810 (Div. 2) d. rain (segment tree difference)
[Openstack] keystone,nova
[principle] several ways of horizontal penetration
Differences and principles of bio, NiO and AIO
"Weilai Cup" 2022 Niuke summer multi school training camp 1 J serval and essay (heuristic merger)
[kvm] create virtual machine from kickstart file