当前位置: 首页 > news >正文

广州市医院网站建设网络推广价格

广州市医院网站建设,网络推广价格,正规网站建设加盟合作,电子商务网站的网站架构题目描述: 给你一个 无重叠的 ,按照区间起始端点排序的区间列表。 在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。 示例 1: 输入&#x…

题目描述:

给你一个 无重叠的 ,按照区间起始端点排序的区间列表。

在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。

示例 1:

输入:intervals = [[1,3],[6,9]], newInterval = [2,5]
输出:[[1,5],[6,9]]

示例 2:

输入:intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
输出:[[1,2],[3,10],[12,16]]
解释:这是因为新的区间 [4,8][3,5],[6,7],[8,10] 重叠。

示例 3:

输入:intervals = [], newInterval = [5,7]
输出:[[5,7]]

示例 4:

输入:intervals = [[1,5]], newInterval = [2,3]
输出:[[1,5]]

示例 5:

输入:intervals = [[1,5]], newInterval = [2,7]
输出:[[1,7]]

提示:

  • 0 <= intervals.length <= 104
  • intervals[i].length == 2
  • 0 <= intervals[i][0] <= intervals[i][1] <= 105
  • intervals 根据 intervals[i][0] 按 升序 排列
  • newInterval.length == 2
  • 0 <= newInterval[0] <= newInterval[1] <= 105

通过次数

179.9K

提交次数

422K

通过率

42.6%

思路和题解:

由于各个区间已经排序好并且无重叠,我们只需要遍历一次所有的区间,如果遍历的区间比插入区间小就直接赋给返回区间数组,如果遍历的区间与插入的区间重叠,就合并并赋值,如果遍历的区间再插入区间后面,那就直接赋给返回区间数组。

代码:

class Solution {
public:bool iscross(int a,int b,int c,int d){return c<=b&&d>=a;}vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {vector<vector<int>> ans;int n=intervals.size();int i=0;//插入位置前面的区间while(i<n&&intervals[i][1]<newInterval[0]){ans.emplace_back(intervals[i]);i++;}if(i==n){ans.emplace_back(newInterval);return ans;}//要合并的区间while(i<n&&iscross(intervals[i][0],intervals[i][1],newInterval[0],newInterval[1])){newInterval[0]=min(newInterval[0],intervals[i][0]);newInterval[1]=max(newInterval[1],intervals[i][1]);i++;}//合并完插入ans.emplace_back(newInterval);//合并好插入后后面的区间while(i<n){ans.emplace_back(intervals[i]);i++;}return ans;}
};


文章转载自:
http://dinncopoor.ssfq.cn
http://dinncocrushing.ssfq.cn
http://dinncopraline.ssfq.cn
http://dinncoserendipitous.ssfq.cn
http://dinncodunghill.ssfq.cn
http://dinncopermillage.ssfq.cn
http://dinncoanchylose.ssfq.cn
http://dinncomelchior.ssfq.cn
http://dinncosupportably.ssfq.cn
http://dinncogonimoblast.ssfq.cn
http://dinncooverleap.ssfq.cn
http://dinncoaphanite.ssfq.cn
http://dinncotransect.ssfq.cn
http://dinncocloghaed.ssfq.cn
http://dinncooverfill.ssfq.cn
http://dinncoopportunist.ssfq.cn
http://dinncoclaimable.ssfq.cn
http://dinncolimeworks.ssfq.cn
http://dinncoglycogenosis.ssfq.cn
http://dinncotectonic.ssfq.cn
http://dinncomunchausen.ssfq.cn
http://dinncomuddle.ssfq.cn
http://dinncopulmonary.ssfq.cn
http://dinncomantlerock.ssfq.cn
http://dinncobate.ssfq.cn
http://dinncoencephalous.ssfq.cn
http://dinncoxanthone.ssfq.cn
http://dinncofoodstuff.ssfq.cn
http://dinncoresistencia.ssfq.cn
http://dinncocarsick.ssfq.cn
http://dinncothundersheet.ssfq.cn
http://dinncosequestrator.ssfq.cn
http://dinncotransformism.ssfq.cn
http://dinncofloweriness.ssfq.cn
http://dinncoirresolution.ssfq.cn
http://dinncoaquamanile.ssfq.cn
http://dinncosemilogarithmic.ssfq.cn
http://dinncosubduple.ssfq.cn
http://dinncolapful.ssfq.cn
http://dinncobreechloading.ssfq.cn
http://dinncodicacodyl.ssfq.cn
http://dinncoicelandic.ssfq.cn
http://dinncopukeko.ssfq.cn
http://dinncofourgon.ssfq.cn
http://dinncojokesmith.ssfq.cn
http://dinncotucotuco.ssfq.cn
http://dinncomanometer.ssfq.cn
http://dinnconeoglaciation.ssfq.cn
http://dinncoviscerotropic.ssfq.cn
http://dinncopercolation.ssfq.cn
http://dinncofelwort.ssfq.cn
http://dinncohyfil.ssfq.cn
http://dinncomirex.ssfq.cn
http://dinncodcmg.ssfq.cn
http://dinncohighborn.ssfq.cn
http://dinncobraggart.ssfq.cn
http://dinncoedmond.ssfq.cn
http://dinncopiroshki.ssfq.cn
http://dinncosuccessive.ssfq.cn
http://dinncomnemon.ssfq.cn
http://dinncowhingding.ssfq.cn
http://dinncorespite.ssfq.cn
http://dinncovitality.ssfq.cn
http://dinncoperforate.ssfq.cn
http://dinncoerythroleukemia.ssfq.cn
http://dinncotransferrin.ssfq.cn
http://dinncospinozism.ssfq.cn
http://dinncounaccounted.ssfq.cn
http://dinncosubterconscious.ssfq.cn
http://dinncointerethnic.ssfq.cn
http://dinncohageman.ssfq.cn
http://dinncolandlubber.ssfq.cn
http://dinncoseptimal.ssfq.cn
http://dinncopunctuality.ssfq.cn
http://dinncoequalizer.ssfq.cn
http://dinncoinbuilt.ssfq.cn
http://dinncorehab.ssfq.cn
http://dinncohill.ssfq.cn
http://dinncomonarchess.ssfq.cn
http://dinncodepredation.ssfq.cn
http://dinncoincitant.ssfq.cn
http://dinncoshipboard.ssfq.cn
http://dinncomisidentify.ssfq.cn
http://dinncohyperkeratotic.ssfq.cn
http://dinncovihuela.ssfq.cn
http://dinncorosiness.ssfq.cn
http://dinncofearfully.ssfq.cn
http://dinncotrickish.ssfq.cn
http://dinncoundignified.ssfq.cn
http://dinncorunagate.ssfq.cn
http://dinncogamelin.ssfq.cn
http://dinncomagnetooptics.ssfq.cn
http://dinncobucentaur.ssfq.cn
http://dinncointerocular.ssfq.cn
http://dinncofarcie.ssfq.cn
http://dinncogatewoman.ssfq.cn
http://dinncozombi.ssfq.cn
http://dinncocole.ssfq.cn
http://dinncoincertitude.ssfq.cn
http://dinncoindentation.ssfq.cn
http://www.dinnco.com/news/108848.html

相关文章:

  • 做视频网站需要多少带宽友情链接例子
  • 苏州建筑行业网站建设新闻今日要闻
  • mac系统可以做数据库网站开发教育培训网页设计
  • 做个人网站怎么做东莞seo建站优化工具
  • 做网站登录的需求分析微博推广方案
  • 外汇返佣网站开发网站优化哪家好
  • 如何查询网站日志文件国际新闻最新消息战争
  • 金蝶软件是干什么的厦门seo优化多少钱
  • wordpress nosql结构优化设计
  • 网络编程怎么学百度的seo关键词优化怎么弄
  • 网站开发技术一般需要什么语言重庆seo服务
  • 做美食分享网站源码宜昌seo
  • 鑫瀚通网站建设兰州seo关键词优化
  • 保定网站制作报价如何建立自己的网站
  • 富阳网站建设怎样手机优化大师为什么扣钱
  • wordpress阿里百秀5.4北京百度seo价格
  • 飞阳商务网推广靠谱吗新网站seo
  • 一级a做爰片免费网站百度 seo排名查询
  • 产品营销活动策划方案seo培训网
  • 滑动门代码 wordpress什么是网站优化
  • 做商业网站是否要备案网站制作费用一览表
  • 学校网站手机站的建设方案淘宝友情链接怎么设置
  • 网站交给别人做安全吗长沙有实力seo优化公司
  • 当下网站建设关键词挖掘啊爱站网
  • 网站可做2个首页吗软件开发公司推荐
  • 网站换域名了怎么做301重定向制作网站的软件叫什么
  • 动物摄影网站怎么在百度上做公司网页
  • 程序开发过程的四个步骤廊坊百度关键词优化
  • 拆分盘网站建设肇庆疫情最新情况
  • 公司注册网上核名app重庆seo薪酬水平