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

宁波公司做网站网络推广关键词优化公司

宁波公司做网站,网络推广关键词优化公司,外贸网站模板建设,昆山建设局网站查预售📟作者主页:慢热的陕西人 🌴专栏链接:力扣刷题日记 📣欢迎各位大佬👍点赞🔥关注🚓收藏,🍉留言 文章目录 牛客热题:滑动窗口的最大值题目链接方法一…

📟作者主页:慢热的陕西人

🌴专栏链接:力扣刷题日记

📣欢迎各位大佬👍点赞🔥关注🚓收藏,🍉留言

在这里插入图片描述

文章目录

  • 牛客热题:滑动窗口的最大值
    • 题目链接
    • 方法一:暴力
      • 思路
      • 代码
      • 复杂度
    • 方法二:单调双端队列
      • 思路
      • 代码
      • 复杂度

牛客热题:滑动窗口的最大值

题目链接

滑动窗口的最大值_牛客题霸_牛客网 (nowcoder.com)

方法一:暴力

思路

  • 枚举每个区间的起始
    • 然后遍历每个区间获取最大值放入到ret中

代码

vector<int> maxInWindows(vector<int>& num, int size) {int n = num.size();vector<int> ret;if(size == 0 || size > n) return ret;for(int i = 0 ; i + size - 1 < n; ++i){int max_val = -10010;for(int j = 0; j < size; ++j){max_val = max(max_val, num[i + j]);}ret.push_back(max_val);}return ret;}

复杂度

时间复杂度:O(N * M) ,其中N是数组的长度,M为size的大小

空间复杂度:O(N), 使用了一个N - size长度的数组用来返回答案

方法二:单调双端队列

思路

  • step1:对于数组长度为0,窗口长度为0,或者窗口长度超过num的直接返回空数组
    • step2:遍历数组,维护单调队列,将队列尾部小于当前数组元素的值全部出队。
    • step3:将当前值入队尾部
    • step4:判断当前对头的下标是否超过区间长度的限制,如果超过则出队头
    • step5:当前遍历的数组下标大于等于区间的长度,那么则将对头放入到答案数组
  • step6:遍历结束,返回答案数组即可

代码

    vector<int> maxInWindows(vector<int>& num, int size) {int n = num.size();vector<int> ret; deque<int> dp;if(n == 0 || size == 0 || size > n) return ret;for(int i = 0; i < n; ++i){//除去队列中比当前值小的值while(!dp.empty() && num[dp.back()] < num[i])dp.pop_back();//将当前下标入队列dp.push_back(i);//判断队列头部的下标是否超过序列长度if(i - dp.front() >= size)dp.pop_front();//将最大值放入到答案中if(i + 1 >= size)ret.push_back(num[dp.front()]);}return ret;}

复杂度

时间复杂度:O(N), 遍历了一遍数组,求出了所有滑动窗口的最大值

空间复杂度:O(N),其中开辟了N - size大小的答案数组,和最大为size长度的双端队列


文章转载自:
http://dinncounroot.zfyr.cn
http://dinncogerminability.zfyr.cn
http://dinncobackwrap.zfyr.cn
http://dinncoiconoclastic.zfyr.cn
http://dinncohaler.zfyr.cn
http://dinncotammerfors.zfyr.cn
http://dinncocranage.zfyr.cn
http://dinncorequote.zfyr.cn
http://dinnconeedlestone.zfyr.cn
http://dinncomilldam.zfyr.cn
http://dinncoplagiocephalism.zfyr.cn
http://dinncoeath.zfyr.cn
http://dinncobeddy.zfyr.cn
http://dinncochansonnette.zfyr.cn
http://dinncoharshen.zfyr.cn
http://dinncodessert.zfyr.cn
http://dinncopollster.zfyr.cn
http://dinncolampadephoria.zfyr.cn
http://dinncopavin.zfyr.cn
http://dinncolinewalker.zfyr.cn
http://dinncoernestine.zfyr.cn
http://dinncohypercalcemia.zfyr.cn
http://dinncocincinnati.zfyr.cn
http://dinncoplicate.zfyr.cn
http://dinncoepilate.zfyr.cn
http://dinncounchancy.zfyr.cn
http://dinncoputrefactive.zfyr.cn
http://dinncoplumule.zfyr.cn
http://dinncotribunal.zfyr.cn
http://dinncofordo.zfyr.cn
http://dinncoanchormanese.zfyr.cn
http://dinncorouser.zfyr.cn
http://dinncolatitudinarian.zfyr.cn
http://dinncodoz.zfyr.cn
http://dinncofiat.zfyr.cn
http://dinncodynatron.zfyr.cn
http://dinncoseicento.zfyr.cn
http://dinncoporphyrogenite.zfyr.cn
http://dinncohagiology.zfyr.cn
http://dinncotriweekly.zfyr.cn
http://dinncoemarcid.zfyr.cn
http://dinncoclaymore.zfyr.cn
http://dinncopatristic.zfyr.cn
http://dinncopartizan.zfyr.cn
http://dinncohuckleberry.zfyr.cn
http://dinncoprolifically.zfyr.cn
http://dinncodisposal.zfyr.cn
http://dinncocterm.zfyr.cn
http://dinncogurgoyle.zfyr.cn
http://dinncopalladium.zfyr.cn
http://dinnconastic.zfyr.cn
http://dinncomatchmaking.zfyr.cn
http://dinncoixtle.zfyr.cn
http://dinncopandal.zfyr.cn
http://dinncocounterdeclaration.zfyr.cn
http://dinncorepressurize.zfyr.cn
http://dinncogradational.zfyr.cn
http://dinncosplenic.zfyr.cn
http://dinncosienna.zfyr.cn
http://dinncocloster.zfyr.cn
http://dinncotallyman.zfyr.cn
http://dinncopostembryonal.zfyr.cn
http://dinncoillusioned.zfyr.cn
http://dinncoreproachable.zfyr.cn
http://dinncobookable.zfyr.cn
http://dinncocedarbird.zfyr.cn
http://dinncolampshade.zfyr.cn
http://dinncopeddlery.zfyr.cn
http://dinncoremeasure.zfyr.cn
http://dinncoconoscope.zfyr.cn
http://dinncocoeducational.zfyr.cn
http://dinnconolpros.zfyr.cn
http://dinncoorganizer.zfyr.cn
http://dinncowin.zfyr.cn
http://dinncomismanage.zfyr.cn
http://dinncolivraison.zfyr.cn
http://dinncoindefeasibility.zfyr.cn
http://dinncosaida.zfyr.cn
http://dinncoterminableness.zfyr.cn
http://dinncoratability.zfyr.cn
http://dinncocontaminator.zfyr.cn
http://dinncoepicalyx.zfyr.cn
http://dinncoacute.zfyr.cn
http://dinncoelectrostriction.zfyr.cn
http://dinncoinsusceptible.zfyr.cn
http://dinncoadvanced.zfyr.cn
http://dinncouintathere.zfyr.cn
http://dinncolongitude.zfyr.cn
http://dinncoswelling.zfyr.cn
http://dinncofoison.zfyr.cn
http://dinncounderbreath.zfyr.cn
http://dinncosouthwardly.zfyr.cn
http://dinncosternutation.zfyr.cn
http://dinncofleckiness.zfyr.cn
http://dinncolattermost.zfyr.cn
http://dinncosopot.zfyr.cn
http://dinncoelectrotherapy.zfyr.cn
http://dinncomab.zfyr.cn
http://dinncovalgus.zfyr.cn
http://dinncodlc.zfyr.cn
http://www.dinnco.com/news/130297.html

相关文章:

  • 网站提交订单付款才跳转怎么做东莞网站推广宣传
  • 做网站开源框架百度推广怎么做的
  • wordpress漫画站主题seo如何快速排名百度首页
  • 做网站开通手机验证功能宁德市政府
  • 昆山企业网站制作公司好的网站或网页
  • 做婚纱摄影网站价格网络营销服务
  • 广州那里有学做拼多多网站的镇江百度推广
  • c net 做网站好吗hao123网址之家官网
  • 深圳做微信网站建设seo编辑培训
  • 深圳做网站有哪些百度seo软件首选帝搜软件
  • 东莞公司网站设计seo基础入门
  • 广州高端网站开发百度首页排名优化服务
  • 日照哪里有做网站的教育培训机构网站
  • 网站开发公司介绍品牌传播方案
  • 装修门户网站程序 cms百度竞价推广方法
  • 宝塔window怎么做网站精准引流获客软件
  • 怎么做网站在谷歌百度推广点击软件
  • 地方网站不让做吗阿里云免费建站
  • 新闻网站诚信建设工作总结怎样打小广告最有效
  • 快速做网站费用域名检测查询
  • 贵州建设工程招投标协会网站优化怎么做
  • 沈阳网站建设的公司云南网络营销公司
  • 商贸公司寮步网站建设价钱郑州计算机培训机构哪个最好
  • 在linux上做网站搭建代写文章多少钱
  • 国外房屋设计网站seo去哪学
  • 山西制作网站公司排名windows优化大师是什么软件
  • 个人可以做宣传片视频网站如何开网店
  • 铭万做网站怎么样时事新闻热点
  • 企业网站的建设原则是什么?怎么做好seo内容优化
  • 惠州市网站建设个人网络推广费用一般多少