当前位置:网站首页>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
边栏推荐
- Handling record of electric skateboard detained by traffic police
- SSM framework integration
- Shell script -- condition judgment
- Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
- [research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
- 1107 social clusters (30 points)
- [research materials] 2022q1 game preferred casual game distribution circular - Download attached
- 论文阅读_中文医疗模型_ eHealth
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
猜你喜欢

2022-02-11 daily clock in: problem fine brush

Silent authorization login and registration of wechat applet

First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT

Source insight garbled code solution

C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement

Interface frequency limit access

MC Layer Target
![[luatos sensor] 2 air pressure bmp180](/img/88/2a6caa5fec95e54e3fb09c74ba8ae6.jpg)
[luatos sensor] 2 air pressure bmp180

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article

Three representations of signed numbers: original code, inverse code and complement code
随机推荐
文献阅读_基于多模态数据语义融合的旅游在线评论有用性识别研究(中文文献)
1099 build a binary search tree (30 points)
Concurrent operation memory interaction
1106 lowest price in supply chain (25 points)
Preparation for school and professional cognition
Do you know UVs in modeling?
Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
[luatos sensor] 2 air pressure bmp180
编译GCC遇到的“pthread.h” not found问题
[XSS bypass - protection strategy] understand the protection strategy and better bypass
【工具跑SQL盲注】
Interface frequency limit access
1110 complete binary tree (25 points)
[research materials] 2021 China's game industry brand report - Download attached
M1 Pro install redis
@RequestMapping
[backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times
[develop wechat applet local storage with uni app]
1115 counting nodes in a BST (30 points)
Kept hot standby and haproxy