当前位置:网站首页>力扣方法总结:查找类
力扣方法总结:查找类
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值即为其下标。
边栏推荐
- Handwritten call, apply, bind
- SQLyog远程连接centos7系统下的MySQL数据库
- Feature Engineering: summary of common feature transformation methods
- 利用超球嵌入来增强对抗训练
- 【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
- Nacos service registration in the interface
- install.img制作方式
- In the era of short video, how to ensure that works are more popular?
- open3d学习笔记四【表面重建】
- Open3d learning notes II [file reading and writing]
猜你喜欢

open3d学习笔记三【采样与体素化】

用MLP代替掉Self-Attention

It's great to save 10000 pictures of girls

Income in the first month of naked resignation

Feature Engineering: summary of common feature transformation methods

Command line is too long

【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》

【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》
![How do vision transformer work? [interpretation of the paper]](/img/93/5f967b876fbd63c07b8cfe8dd17263.png)
How do vision transformer work? [interpretation of the paper]

Embedding malware into neural networks
随机推荐
图像增强的几个方法以及Matlab代码
What if the laptop task manager is gray and unavailable
【雙目視覺】雙目矯正
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
Open3d learning notes II [file reading and writing]
open3d环境错误汇总
Sequence problem for tqdm and print
[C # note] the data in DataGridView saved in WinForm is excel and CSV
The internal network of the server can be accessed, but the external network cannot be accessed
Backup, recovery and repair of XFS file system
How do vision transformer work? [interpretation of the paper]
Network metering - transport layer
用C# 语言实现MYSQL 真分页
(15) Flick custom source
It's great to save 10000 pictures of girls
【MobileNet V3】《Searching for MobileNetV3》
CVPR19-Deep Stacked Hierarchical Multi-patch Network for Image Deblurring论文复现
使用C#语言来进行json串的接收
【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》
w10升级至W11系统,黑屏但鼠标与桌面快捷方式能用,如何解决