当前位置:网站首页>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 .边栏推荐
- Codeforces round 810 (Div. 2) d. rain (segment tree difference)
- Install the laser of ROS_ scan_ Problems encountered in match library (I)
- 9.延迟队列
- 全屋WiFi方案:Mesh路由器组网和AC+AP
- How to execute insert into select from job in SQL client
- Why are there so many unknowns when opengauss starts?
- C language - character array - string array - '\0' -sizeof-strlen() -printf()
- 为什么opengauss启动的时候这么多的unknown?
- 信号处理中的反傅里叶变换(IFFT)原理
- When defining an array, the size must be constant
猜你喜欢

Common components of solder pad (2021.4.6)

10. Fallback message
![[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

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

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

Record of problems encountered in ROS learning

不会就坚持63天吧 最大的异或

Deep learning training strategy -- warming up the learning rate

MySQL gets the maximum value record by field grouping

不会就坚持58天吧 实现前缀树
随机推荐
店铺排名问题,如何解决?
Methods of using multiple deformations on an element
数据库SQL语句实现数据分解的函数查询
编译与链接
不会就坚持70天吧 数组中第k大的数
不会就坚持65天吧 只出现一次的数字
Some problems about pointers
Model tuning, training model trick
C语言:typedef知识点总结
大佬们flink的JDBC SQL Connector现在不支持所有的数据库吗,例如vertica?
Multi card training in pytorch
Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
Shielding ODBC load balancing mode in gbase 8A special scenarios?
Applet: Area scrolling, pull-down refresh, pull-up load more
[kvm] common commands
[k210 stepping pit] pytorch model is converted to kmodel and used on dock. (ultimately not achieved)
Blood cases caused by < meta charset=UTF-8> -- Analysis of common character codes
不会就坚持63天吧 最大的异或
Svg -- loading animation
The structure pointer must be initialized, and the pointer must also be initialized