当前位置:网站首页>力扣方法总结:查找类
力扣方法总结:查找类
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值即为其下标。
边栏推荐
- 【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
- 用MLP代替掉Self-Attention
- [Sparse to Dense] Sparse to Dense: Depth Prediction from Sparse Depth samples and a Single Image
- It's great to save 10000 pictures of girls
- Summary of solving the Jetson nano installation onnx error (error: failed building wheel for onnx)
- C # connect to MySQL database
- Embedding malware into neural networks
- 【MobileNet V3】《Searching for MobileNetV3》
- Jetson nano installation tensorflow stepping pit record (scipy1.4.1)
- TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
猜你喜欢

应对长尾分布的目标检测 -- Balanced Group Softmax

图像增强的几个方法以及Matlab代码

【Batch】learning notes
![[binocular vision] binocular stereo matching](/img/93/2e916038f0e7d0c7b3bf64f8dc1b4e.png)
[binocular vision] binocular stereo matching
![[binocular vision] binocular correction](/img/fe/27fda48c36ca529eec21c631737526.png)
[binocular vision] binocular correction
![Open3d learning notes 1 [first glimpse, file reading]](/img/68/68ea87817dbf788591216a32c9375b.png)
Open3d learning notes 1 [first glimpse, file reading]

【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》

用于类别增量学习的动态可扩展表征 -- DER

【MobileNet V3】《Searching for MobileNetV3》

【MobileNet V3】《Searching for MobileNetV3》
随机推荐
[mixup] mixup: Beyond Imperial Risk Minimization
[binocular vision] binocular correction
Specification for package drawing
联邦学习下的数据逆向攻击 -- GradInversion
open3d学习笔记四【表面重建】
【Random Erasing】《Random Erasing Data Augmentation》
Programmers can only be 35? The 74 year old programmer in the United States has been programming for 57 years and has not retired
学习写文章格式
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
Eklavya -- infer the parameters of functions in binary files using neural network
将恶意软件嵌入到神经网络中
Backup, recovery and repair of XFS file system
How to clean up logs on notebook computers to improve the response speed of web pages
Business architecture diagram
Several methods of image enhancement and matlab code
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
Solve the problem of latex picture floating
Open3d learning notes 1 [first glimpse, file reading]
Thesis tips
应对长尾分布的目标检测 -- Balanced Group Softmax