当前位置:网站首页>leetcode435. Non overlapping interval
leetcode435. Non overlapping interval
2022-07-03 04:58:00 【Day by day, the dish chicken Jie!!】
One : The analects of Confucius
different No common goal, no common cause to cooperate We have no reason to hold our own judgment Look at what others have experienced , There is no real empathy when you start again , What we can do is to respect the views of others , Keep your attitude .
Two : subject

3、 ... and : Upper code
class Solution {
public:
/** Ideas :1. Here, we still handle it in ascending order according to the second element of the interval array [[1,2],[1,3],[2,3],[3,4]] Here, as long as the right boundary of our interval array is less than the left boundary of the next array Then our final interval is Non overlapping . */
static bool cmp(const vector<int> & v1,const vector<int>& v2) {
return v1[1] < v2[1];
}
int eraseOverlapIntervals(vector<vector<int>>& intervals) {
sort(intervals.begin(),intervals.end(),cmp);
int temp = intervals[0][1];// First right boundary
int count = 1;// The number of interval arrays that meet the requirements ( Record first An interval array )
for(int i = 0; i < intervals.size(); i++) {
if(temp <= intervals[i][0]){
// If it is smaller than the left boundary , Then update the right boundary , At the same time, record the number of interval arrays that meet the requirements
temp = intervals[i][1];
count++;
}
}
return intervals.size() - count;
}
};
come on. Good night, A stranger
边栏推荐
- Market status and development prospects of the global autonomous marine glider industry in 2022
- UiPath实战(08) - 选取器(Selector)
- [set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- RT thread flow notes I startup, schedule, thread
- Preparation for school and professional cognition
- Learning record of arouter principle
- MySQL winter vacation self-study 2022 12 (3)
- Kept hot standby and haproxy
- [research materials] 2021 China's game industry brand report - Download attached
猜你喜欢

ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)

Unity tool Luban learning notes 1

【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)

Keepalived热备与HAProxy

Career planning of counter attacking College Students

【XSS绕过-防护策略】理解防护策略,更好的绕过

The reason why the entity class in the database is changed into hump naming

SSM framework integration

The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
![[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa](/img/a9/92059db74ccde03b84c69dfce35b37.jpg)
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
随机推荐
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
逆袭大学生的职业规划
[luatos sensor] 1 light sensing bh1750
Wechat applet distance and map
Shuttle + alluxio accelerated memory shuffle take-off
Kept hot standby and haproxy
Review the configuration of vscode to develop golang
M1 Pro install redis
Thesis reading_ Tsinghua Ernie
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
The reason why the entity class in the database is changed into hump naming
Sdl2 + OpenGL glsl practice (Continued)
Source insight garbled code solution
雇佣收银员(差分约束)
Flutter monitors volume to realize waveform visualization of audio
Hire cashier (differential constraint)
Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
1111 online map (30 points)
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached