当前位置:网站首页>Interval merging board
Interval merging board
2022-04-22 02:36:00 【Bzdhxs_ nt】
Time complexity O ( n ) O(n) O(n)
greedy
using pll = pair<int,int>;
vector<pll> seg;
void merge(){
vector<pll> res;
int st = -inf,ed = -inf;
for(auto s:seg){
if(ed < s.first){
if(st!=-inf) res.push_back({
st,ed});
st = s.first, ed = s.second;
}
else ed = max(ed,s.second);
}
if(st != -inf) res.push_back({
st,ed});
seg = res;
}
版权声明
本文为[Bzdhxs_ nt]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220233169003.html
边栏推荐
- STM32 can communication experiment
- Unity game optimization - third edition reading notes Chapter 1 analyze performance problems
- STM32 CAN通信实验
- Fluent music player audioplayer
- 二叉排序树基本性质详解
- Explain the mathematical process of neural network like a pile of LEGO
- Digital twin tank warfare, technology promotes battlefield information digitization
- golang 1.8泛型测试
- unapp封装一个加载动画
- What do you learn about programming
猜你喜欢
随机推荐
Go use options mode to set parameters
flutter 不用状态栏的导航栏
The night can also be colorful, and the full-color night vision system can be realized by deep learning
Binary cross entropy loss function
Inductive bias
Line feed in string value when sqlserver parses JSON
ctf-wiki本地搭建记录
[➾ leetcode Sword means offer 12. Path in Matrix (simple)]
软件测试·坏味道
二元交叉熵损失函数
(进阶)C函数调用
【※ LeetCode 剑指 Offer 13. 机器人的运动范围(简单)】
Shit, someone poisoned my code comments?
Opencv calculates the gradient feature of the image
Soxinda won 100 million yuan investment from Financial Street capital
[Xiao Yang takes you to play with C language] circular structure (detailed explanation)
Unapp encapsulates a loading animation
Interview question: use the program to realize the alternating printing of odd and even numbers from 0 to 100 by two threads
创建双向链表(详解)
The flitter does not use the navigation bar of the status bar









