当前位置:网站首页>Won't you just stick to 69 days? Merge range
Won't you just stick to 69 days? Merge range
2022-07-29 04:16:00 【A little Ming】

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()][]);
}
}
author :LeetCode-Solution
link :https://leetcode.cn/problems/SsGoHC/solution/he-bing-qu-jian-by-leetcode-solution-ghjl/
source : Power button (LeetCode)
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .边栏推荐
- Do you have a boss to help me check whether the parameter configuration of the Flink SQL connection Kafka authentication Kerberos is wrong
- C language - character array - string array - '\0' -sizeof-strlen() -printf()
- 不会就坚持70天吧 数组中第k大的数
- Machine vision Series 1: Visual Studio 2019 dynamic link library DLL establishment
- Pix2.4.8 from start to installation (2021.4.4)
- When array is used as a function parameter, it is better to use the array size as a function parameter
- 不会就坚持63天吧 最大的异或
- Solution: module 'xlrd' has no attribute 'open_ Error reporting of workbook '
- 11.备份交换机
- Fu Yingna: Yuan universe is the new generation of Internet!
猜你喜欢

SVG--loading动画

不会就坚持65天吧 只出现一次的数字

Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation

Two forms of softmax cross entropy + numpy implementation

Fu Yingna: Yuan universe is the new generation of Internet!

不会就坚持67天吧 平方根

信号处理中的反傅里叶变换(IFFT)原理

不会就坚持68天吧 狒狒吃香蕉

Object detection: object_ Detection API +ssd target detection model

Common components of solder pad (2021.4.6)
随机推荐
The difference between dynamic, VaR and object in fluent
Mmdetection preliminary use
C语言:浅谈各种复杂的声明
Solution: module 'xlrd' has no attribute 'open_ Error reporting of workbook '
Implementation of jump connection of RESNET (pytorch)
"Weilai Cup" 2022 Niuke summer multi school training camp 2H
Const char* and char*, string constants
通过js来实现一元二次方程的效果,输入a,b,c系数后可计算出x1和x2的值
Value transmission and address transmission of C language, pointer of pointer
Applet: Area scrolling, pull-down refresh, pull-up load more
Install the laser of ROS_ scan_ Problems encountered in match library (I)
[kvm] create virtual machine from kickstart file
C语言:结构体简单语法总结
Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
Machine vision Series 2: vs DLL debugging
11.备份交换机
When defining an array, the size must be constant
12. Priority queue and inert queue
Svg -- loading animation
Some problems about pointers