当前位置:网站首页>区间合并板子
区间合并板子
2022-04-22 02:33:00 【Bzdhxs_nt】
时间复杂度 O ( n ) O(n) O(n)
贪心
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://blog.csdn.net/qq_51687628/article/details/124329707
边栏推荐
- Development of smart party building system and construction of information management platform for smart team members
- 创建双向链表(详解)
- Pycharm同时执行多个脚本文件
- Complete solution of closure operation in Discrete Mathematics
- MySQL8. 0 zero foundation beginner level: from bronze to diamond
- [※ leetcode refers to the path in offer 12. Matrix (simple)]
- postgresql中在查询结果中将字符串转换为整形或浮点型
- WSOLA principle and MATLAB simulation
- Information Security Overview
- Why does MySQL index use B + tree instead of jump table?
猜你喜欢

【※ LeetCode 剑指 Offer 13. 机器人的运动范围(简单)】

How does ECS connect to ad domain or LDAP user source

刷题笔记:剑指offer 04.二维数组中的查找——一个报错

SED and awk tools of shell

编程主要学什么

Unity game optimization - third edition reading notes Chapter 1 analyze performance problems

吴恩达机器学习作业——逻辑回归

Pychar executes multiple script files at the same time

How to restrict the unity of code

开发管理·华为IPD
随机推荐
Development of smart party building system and construction of information management platform for smart team members
In PostgreSQL, convert a string to an integer or floating-point type in the query result
CTF wiki local construction record
JS Baidu map positioning
Ren Jie, chief scientist of rongyun: the Internet is unstoppable, but there are always young people
[论文阅读] Active Class Incremental Learning for Imbalanced Datasets
flutter 不用状态栏的导航栏
Flutter跳转界面
Uniapp handles forced refresh
Introduction to Alibaba's super large-scale Flink cluster operation and maintenance system
The youqilin 22.04 lts version system will be released on April 22, equipped with the new ukui 3.1
Development management · Huawei IPD
Binary cross entropy loss function
开发管理·华为IPD
Training set: alexnet classification
C指针和数组深度汇总
flutter 音乐播放器audioplayer
WSOLA principle and MATLAB simulation
Explain the mathematical process of neural network like a pile of LEGO
Dump mangodb data using Navicat