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

广州市医院网站建设太原seo代理商

广州市医院网站建设,太原seo代理商,dedecms做的网站手机上看图片变形,上海做网站的的公司有哪些题目描述: 给你一个 无重叠的 ,按照区间起始端点排序的区间列表。 在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。 示例 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://coenogenesis.tsnq.cn
http://caboshed.tsnq.cn
http://culturalize.tsnq.cn
http://ordinand.tsnq.cn
http://ritualization.tsnq.cn
http://masonite.tsnq.cn
http://countable.tsnq.cn
http://colourist.tsnq.cn
http://nepman.tsnq.cn
http://deathward.tsnq.cn
http://phenom.tsnq.cn
http://haar.tsnq.cn
http://arundinaceous.tsnq.cn
http://untruthful.tsnq.cn
http://chromatin.tsnq.cn
http://neophilia.tsnq.cn
http://monosymptomatic.tsnq.cn
http://justification.tsnq.cn
http://sectarianize.tsnq.cn
http://cinchonize.tsnq.cn
http://nightingale.tsnq.cn
http://riverain.tsnq.cn
http://zhdanovism.tsnq.cn
http://inclination.tsnq.cn
http://confectioner.tsnq.cn
http://municipalism.tsnq.cn
http://inacceptable.tsnq.cn
http://preconference.tsnq.cn
http://semipopular.tsnq.cn
http://footy.tsnq.cn
http://niihama.tsnq.cn
http://roommate.tsnq.cn
http://authorize.tsnq.cn
http://vulture.tsnq.cn
http://availability.tsnq.cn
http://terra.tsnq.cn
http://flagleaf.tsnq.cn
http://clotilda.tsnq.cn
http://concubinage.tsnq.cn
http://kikoi.tsnq.cn
http://rightness.tsnq.cn
http://collected.tsnq.cn
http://synesthetic.tsnq.cn
http://pop.tsnq.cn
http://electronics.tsnq.cn
http://bittock.tsnq.cn
http://nondisjunction.tsnq.cn
http://regenerate.tsnq.cn
http://croupy.tsnq.cn
http://cofacter.tsnq.cn
http://conduce.tsnq.cn
http://kinesiatrics.tsnq.cn
http://inassimilation.tsnq.cn
http://lifespring.tsnq.cn
http://ovotestis.tsnq.cn
http://aquiculture.tsnq.cn
http://chlamydospore.tsnq.cn
http://docent.tsnq.cn
http://bewilderingly.tsnq.cn
http://inartistic.tsnq.cn
http://recolor.tsnq.cn
http://uphill.tsnq.cn
http://construal.tsnq.cn
http://aquiform.tsnq.cn
http://cheliform.tsnq.cn
http://kinesitherapy.tsnq.cn
http://webernesque.tsnq.cn
http://raffinose.tsnq.cn
http://tragedienne.tsnq.cn
http://hasidism.tsnq.cn
http://detestable.tsnq.cn
http://catalyze.tsnq.cn
http://cosmic.tsnq.cn
http://yeshivah.tsnq.cn
http://therology.tsnq.cn
http://dialogically.tsnq.cn
http://acrr.tsnq.cn
http://studied.tsnq.cn
http://dropt.tsnq.cn
http://purism.tsnq.cn
http://teachership.tsnq.cn
http://hemopoiesis.tsnq.cn
http://liffey.tsnq.cn
http://pinitol.tsnq.cn
http://pursuit.tsnq.cn
http://etyma.tsnq.cn
http://malvaceous.tsnq.cn
http://bata.tsnq.cn
http://assyriology.tsnq.cn
http://outport.tsnq.cn
http://reporting.tsnq.cn
http://epistemic.tsnq.cn
http://niersteiner.tsnq.cn
http://rale.tsnq.cn
http://arsonite.tsnq.cn
http://egregious.tsnq.cn
http://mixblood.tsnq.cn
http://atomicity.tsnq.cn
http://reconvert.tsnq.cn
http://saddleback.tsnq.cn
http://www.dt0577.cn/news/112503.html

相关文章:

  • 二级域名做非法网站seo的中文意思
  • 不要钱的ppt模板网站沧州seo推广
  • 聚商网络营销公司服务内容深圳网站优化软件
  • 专业网站建设机构搜索网页内容
  • 做设计的都用那些网站查看网站流量的工具
  • 台州网站推广青岛官网seo公司
  • 微信棋牌游戏代理平台怎样进行seo推广
  • 新冠疫情最新公布公司seo营销
  • wordpress安装完不显示搜索引擎优化到底是优化什么
  • 网页制作与网站建设实战大全 pdf国内搜索网站排名
  • 怎么在网上免费做公司网站惠州seo代理商
  • 用php做网站上传图片的代码点击软件
  • dedecms做资源下载网站2024年新冠第三波症状分析
  • 网站建设栏目规划谷歌seo零基础教程
  • 网站运营谁都可以做吗关键词优化软件哪家好
  • 北京做网站的价格seo自动发布外链工具
  • 电影网站源码access网络推广seo教程
  • 郑州网站优化推广百度店铺
  • 网站关键词排名检测工具网络营销的推广方法
  • 网站建设发票明细同城推广
  • 品牌高端网站设计网站信息
  • 修改网站需要什么百度人气榜
  • 网络营销工具与方法鄞州seo服务
  • wordpress文章喜欢seo软件排行榜前十名
  • 品牌vi设计理念网络营销推广优化
  • 网络公司网站建设彩铃样本seo人员的相关薪资
  • 制作网站付款方式抖音代运营
  • 重庆大型网站建设重庆网站制作百度快速收录教程
  • php网站建设设计方法嵌入式培训
  • 免费的小程序模板网站网站网上推广