当前位置:网站首页>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
边栏推荐
- Career planning of counter attacking College Students
- 带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
- 移动端——uniapp开发记录(公共请求request封装)
- Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
- 并发操作-内存交互操作
- Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
- 动态规划——相关概念,(数塔问题)
- Handling record of electric skateboard detained by traffic police
- The process of browser accessing the website
- Silent authorization login and registration of wechat applet
猜你喜欢
Review the old and know the new: Notes on Data Science
I stepped on a foundation pit today
Handling record of electric skateboard detained by traffic police
Silent authorization login and registration of wechat applet
SSM framework integration
Thesis reading_ Chinese medical model_ eHealth
Symbol of array element product of leetcode simple problem
MPM model and ab pressure test
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
随机推荐
Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
Objects. Requirenonnull method description
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
Kept hot standby and haproxy
JQ style, element operation, effect, filtering method and transformation, event object
文献阅读_基于多模态数据语义融合的旅游在线评论有用性识别研究(中文文献)
[luatos sensor] 2 air pressure bmp180
Shuttle + alluxio accelerated memory shuffle take-off
1095 cars on campus (30 points)
Problems encountered in fuzzy query of SQL statements
On typescript and grammar
Concurrent operation memory interaction
Valentine's day limited withdrawal guide: for one in 200 million of you
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
Review the old and know the new: Notes on Data Science
Introduction to JVM principle
[set theory] binary relation (example of binary relation operation | example of inverse operation | example of composite operation | example of limiting operation | example of image operation)
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
Preparation for school and professional cognition