当前位置:网站首页>力扣方法总结:查找类
力扣方法总结:查找类
2022-07-02 06:28:00 【Villanelle#】
436. 寻找右区间Medium lower_bound
方法2021/11/10
给你一个区间数组 intervals ,其中 intervals[i] = [starti, endi] ,且每个 starti 都 不同 。
区间 i 的 右侧区间 可以记作区间 j ,并满足 startj >= endi ,且 startj 最小化 。
返回一个由每个区间 i 的 右侧区间 在 intervals 中对应下标组成的数组。如果某个区间 i 不存在对应的 右侧区间 ,则下标 i 处的值设为 -1 。
示例:
输入:intervals = [[3,4],[2,3],[1,2]]
输出:[-1,0,1]
解释:对于 [3,4] ,没有满足条件的“右侧”区间。
对于 [2,3] ,区间[3,4]具有最小的“右”起点;
对于 [1,2] ,区间[2,3]具有最小的“右”起点。
利用map容器插入时自动按key排序的性质,使用map容器存储intervals中的左区间值和对应下标,遍历各区间时,使用map容器中的lower_bound
方法找到key中首个>=其右区间值的迭代器,其second值即为其下标。
边栏推荐
- Remplacer l'auto - attention par MLP
- How to clean up logs on notebook computers to improve the response speed of web pages
- How to turn on night mode on laptop
- 用于类别增量学习的动态可扩展表征 -- DER
- 利用Transformer来进行目标检测和语义分割
- 图像增强的几个方法以及Matlab代码
- 【雙目視覺】雙目矯正
- 【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
- Open3d learning notes II [file reading and writing]
- Real world anti sample attack against semantic segmentation
猜你喜欢
简易打包工具的安装与使用
Several methods of image enhancement and matlab code
【MagNet】《Progressive Semantic Segmentation》
Graph Pooling 简析
jetson nano安装tensorflow踩坑记录(scipy1.4.1)
【TCDCN】《Facial landmark detection by deep multi-task learning》
【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
How to turn on night mode on laptop
What if a new window always pops up when opening a folder on a laptop
I'll show you why you don't need to log in every time you use Taobao, jd.com, etc?
随机推荐
open3d学习笔记五【RGBD融合】
CONDA common commands
One book 1078: sum of fractional sequences
Summary of open3d environment errors
【C#笔记】winform中保存DataGridView中的数据为Excel和CSV
【双目视觉】双目立体匹配
Business architecture diagram
将恶意软件嵌入到神经网络中
【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
Apple added the first iPad with lightning interface to the list of retro products
浅谈深度学习中的对抗样本及其生成方法
Meta learning Brief
【MobileNet V3】《Searching for MobileNetV3》
open3d环境错误汇总
jetson nano安装tensorflow踩坑记录(scipy1.4.1)
【MobileNet V3】《Searching for MobileNetV3》
In the era of short video, how to ensure that works are more popular?
多站点高可用部署
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
Rhel7 operation level introduction and switching operation