当前位置:网站首页>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
边栏推荐
- 50 practical applications of R language (36) - data visualization from basic to advanced
- Cross platform plug-in flutter for displaying local notifications_ local_ notifications
- Sprintf formatter abnormal exit problem
- 1103 integer factorization (30 points)
- The process of browser accessing the website
- Thesis reading_ ICD code_ MSMN
- Do you know UVs in modeling?
- 【工具跑SQL盲注】
- Symbol of array element product of leetcode simple problem
- 论文阅读_ICD编码_MSMN
猜你喜欢

论文阅读_ICD编码_MSMN

Thesis reading_ Chinese NLP_ ELECTRA

Career planning of counter attacking College Students

Retirement plan fails, 64 year old programmer starts work again

论文阅读_中文NLP_ELECTRA

Cross platform plug-in flutter for displaying local notifications_ local_ notifications

Shuttle + Alluxio 加速内存Shuffle起飞

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis

Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly

移动端——uniapp开发记录(公共请求request封装)
随机推荐
The 19th Zhejiang I. barbecue
Market status and development prospect prediction of global neutral silicone sealant industry in 2022
1099 build a binary search tree (30 points)
[research materials] 2021 China's game industry brand report - Download attached
MPM model and ab pressure test
Caijing 365 stock internal reference: what's the mystery behind the good father-in-law paying back 50 million?
Kept hot standby and haproxy
【工具跑SQL盲注】
Market status and development prospect prediction of global colorimetric cup cover industry in 2022
1110 complete binary tree (25 points)
1095 cars on campus (30 points)
Source insight garbled code solution
JDBC database operation
[USACO 2009 Dec S]Music Notes
1111 online map (30 points)
Market status and development prospects of the global autonomous marine glider industry in 2022
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
移动端——uniapp开发记录(公共请求request封装)
Why does I start with =1? How does this code work?
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)