当前位置:网站首页>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
边栏推荐
- ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
- Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
- The process of browser accessing the website
- C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
- Problems encountered in fuzzy query of SQL statements
- 【SQL注入点】注入点出现位置、判断
- Cross platform plug-in flutter for displaying local notifications_ local_ notifications
- Compile and decompile GCC common instructions
- Notes | numpy-11 Array operation
- [Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
猜你喜欢
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Preparation for school and professional cognition
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
Handling record of electric skateboard detained by traffic police
RT thread flow notes I startup, schedule, thread
Thesis reading_ Chinese medical model_ eHealth
Unity tool Luban learning notes 1
Review the old and know the new: Notes on Data Science
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
随机推荐
Distinguish between releases and snapshots in nexus private library
1115 counting nodes in a BST (30 points)
Review the old and know the new: Notes on Data Science
关于开学的准备与专业认知
移动端——uniapp开发记录(公共请求request封装)
1114 family property (25 points)
Market status and development prospects of the global automatic tea picker industry in 2022
《牛客刷verilog》Part II Verilog进阶挑战
Introduction to message queuing (MQ)
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
Learn to use the idea breakpoint debugging tool
1118 birds in forest (25 points)
Market status and development prospects of the global IOT active infrared sensor industry in 2022
论文阅读_清华ERNIE
Literature reading_ Research on the usefulness identification of tourism online comments based on semantic fusion of multimodal data (Chinese Literature)
MC Layer Target
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
Market status and development prospect prediction of global fermentation acid industry in 2022
2022-02-12 daily clock in: problem fine brush
【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过