当前位置:网站首页>贪心之区间问题(1)
贪心之区间问题(1)
2022-06-22 17:50:00 【Douglas_LT】
每日一题ing,今天是个medium题力扣435. Non-overlapping Intervals
class Solution {
public:
int eraseOverlapIntervals(vector<vector<int>>& intervals)
{
if(intervals.size()==0)
return 0;
sort(intervals.begin(),intervals.end(),[](vector<int>& a, vector<int>& b)//按照结束时间从小到大排序
{
return a[1]<b[1];
});
int prev=intervals[0][1],sum=0;
for(int i=1;i<intervals.size();i++)
{
if(intervals[i][0]<prev)
sum++;//和前一个区间重叠的区间需要丢弃
else
{
prev=intervals[i][1];
}
}
return sum;
}
};
边栏推荐
- Array implementation of circular linked list
- 数组模拟栈
- [learn shell programming easily]-4. The difference between single quotation marks and double quotation marks, the operation of integer values, the definition of arrays in the shell and the detailed us
- Mysql如何删除数据库表中的某一列
- Golang 實現 Redis(10): 本地原子性事務
- 2022年T电梯修理复训题库及答案
- Explain the startup process of opengauss multithreading architecture in detail
- Cookie加密3+RPC解法
- 腾讯云国际版云服务器欠费说明
- mysql数据库设计
猜你喜欢

第八届 GopherChina 大会蓄势待发!
Golang实现基于Redis的可靠延迟队列

Zero basic programming / reverse learning / over detection (Frida practice)

STM32控制矩阵按键,HAL库,cubeMX配置

postman学习

C sqlsugar, hisql, FreeSQL ORM framework omni-directional performance test comparison sqlserver

Play typical usage scenarios of kubernetes | dashboard for 5 minutes every day
Oracle中dbms_output.put_line的用法实例

A course for New Oriental transformation bilingual live broadcast to bring goods to the project manager

2022重庆幼教产业展览会|高科技玩具益智解压玩具博览会
随机推荐
AUTOCAD——五种标注快捷键
When do project managers particularly want to escape from work?
Zero basic programming / reverse learning / over detection (Frida practice)
Method of activity jump to fragment (intent)
AIOps 智能运维经验分享
平安证券开户安全吗?它和平安银行是什么关系呢?
自定义数据库连接池类: 要求:封闭一个Collection对象的集合类
UE4_ Ue5 make 3dui follow the camera orientation (attached works)
Notes on new reports
Filebeat collects log data and transfers it to redis. Different es indexes are created based on log fields through logstash
Explain the startup process of opengauss multithreading architecture in detail
Jenkins配置项目集成钉钉通知
Zynq UltraScale + RFSoC ZCU111 RF时钟树学习 1
Oracle中dbms_output.put_line的用法实例
Niuke network: minimum coverage substring
[轻松学会shell编程]-4、单引号和双引号的区别、整形数值的运算、shell中数组定义和sed的详细用法
Jenkins中node节点添加之SSH方式2
2022年G2电站锅炉司炉题库及在线模拟考试
ADAU1452开发系统界面与代码数据之间的关系
C sqlsugar, hisql, FreeSQL ORM framework omni-directional performance test comparison sqlserver