Lintcode30 Insert Interval solution 题解
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,题目描述】Given a non-overlapping interval list which is sorted by start point.Insert a new interval into
千家信息网最后更新 2024年09月22日Lintcode30 Insert Interval solution 题解
题目描述】
Given a non-overlapping interval list which is sorted by start point.Insert a new interval into it, make sure the list is still in order and non-overlapping (merge intervals if necessary).
给出一个无重叠的按照区间起始端点排序的区间列表。在列表中插入一个新的区间,你要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。
【题目链接】
http://www.lintcode.com/en/problem/insert-interval/
【题目解析】
用pos记录newInterval应该插入的位置。顺序遍历intervals中的元素,若当前interval的end比newInterval的start还小,则将当前interval加入答案,同时pos+1;若比newInterval大,则直接加入答案;若有overlap,则需要merge,newInterval的start取两者间小的,end取两者间大的。最后在pos的位置插入newInterval即可。
【参考答案】
http://www.jiuzhang.com/solutions/insert-interval/
区间
答案
题目
位置
有序
必要
元素
同时
端点
链接
顺序
若比
无重
参考
排序
起始
题解
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全队伍
plex安卓 连接服务器
青州网络安全名人在美国
安卓手机变声软件开发
党建系统软件开发公司
nginx服务器崩溃怎么办
西安企业办公软件开发
网络安全问题的技术根源是
网络安全法策划书
数据库 数据对账
信宜租房软件开发
数据库查询表中数据
服务器通道管理软件
北京网络技术开发机构
泗洪购买网络技术解决方案
网络安全措施三同步
福建网络安全厂家销售招聘
数据库数值数据类型
一键转发无法与服务器连接
终端服务器超
php访问数据库后处理数据
数据库备份语法
java txt数据库
眼科软件开发
2019无锡网络安全宣传
大疆 软件开发待遇
网络安全知识竞赛怎么登陆
桌面提醒软件开发
任子行网络技术股份有限公司
查看服务器cpu型号