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

需要做网站设计的公司网站优化联系

需要做网站设计的公司,网站优化联系,上海网站开发,沈阳建设网站哪家好2023.9.15 本题我用的暴力双层for循环 unordered_set 解决的,外循环控制字符起始位置,内循环将字符放入 unordered_set,并查找有无重复的元素。 用了一个全局变量记录最长字串的长度,局部变量count记录当前层循环的最长子串长度…

2023.9.15

        本题我用的暴力双层for循环 + unordered_set 解决的,外循环控制字符起始位置,内循环将字符放入 unordered_set,并查找有无重复的元素。  用了一个全局变量记录最长字串的长度,局部变量count记录当前层循环的最长子串长度。 代码如下:

class Solution {
public:int lengthOfLongestSubstring(string s) {if(s.size() == 0) return 0;int ans = 1;for(int i=0; i<s.size(); i++){unordered_set<char> set;set.insert(s[i]);int count = 1;for(int j=i+1; j<s.size(); j++){if(set.find(s[j]) == set.end()) //没找到重复元素{count++;set.insert(s[j]);ans = max(ans , count);}else break;}}return ans;}
};

        暴力循环+每层循环都用了unordered_set,可想而知,时间和空间消耗都相当高... 

        看了下别人的解法,这题还可以用滑动窗口来做。定义一个left指针指向滑动窗口的最左端,for循环的i向前遍历。每当发现重复元素,就不断将set头部元素删除,直到没有重复元素位置。最后不断更新最长子串的长度即可。

        代码如下:

class Solution {
public:int lengthOfLongestSubstring(string s) {if(s.size() == 0) return 0;queue<char> que;int ans = 1;int left = 0;for(int i=0; i<s.size(); i++){while(set.find(s[i]) != set.end()) //找到重复元素了{set.erase(s[left]);left++;}set.insert(s[i]);ans = max(ans , i-left+1);}return ans;}
};


文章转载自:
http://dinncoreinstate.bkqw.cn
http://dinncoadducent.bkqw.cn
http://dinncoforeignism.bkqw.cn
http://dinncosemon.bkqw.cn
http://dinncoparhelic.bkqw.cn
http://dinncoaortic.bkqw.cn
http://dinncomisknowledge.bkqw.cn
http://dinncokickboxing.bkqw.cn
http://dinnconethermost.bkqw.cn
http://dinncothalictrum.bkqw.cn
http://dinncocutthroat.bkqw.cn
http://dinncolevelman.bkqw.cn
http://dinncostir.bkqw.cn
http://dinncotoxin.bkqw.cn
http://dinncoshortgrass.bkqw.cn
http://dinnconulliparity.bkqw.cn
http://dinncopasta.bkqw.cn
http://dinncosolitudinarian.bkqw.cn
http://dinncoignatius.bkqw.cn
http://dinncoprevisional.bkqw.cn
http://dinncodetumescent.bkqw.cn
http://dinncodisciplinarian.bkqw.cn
http://dinncourological.bkqw.cn
http://dinncoraspy.bkqw.cn
http://dinncoesteem.bkqw.cn
http://dinncoantitrinitarian.bkqw.cn
http://dinncomedusoid.bkqw.cn
http://dinncoliberalistic.bkqw.cn
http://dinncosaltern.bkqw.cn
http://dinncodetergency.bkqw.cn
http://dinncoideaed.bkqw.cn
http://dinncoampliate.bkqw.cn
http://dinncounlamented.bkqw.cn
http://dinncopoltfooted.bkqw.cn
http://dinncodrencher.bkqw.cn
http://dinncoperihelion.bkqw.cn
http://dinncoparthian.bkqw.cn
http://dinncomesothorium.bkqw.cn
http://dinncounitard.bkqw.cn
http://dinncopatentee.bkqw.cn
http://dinncospellican.bkqw.cn
http://dinncobiscay.bkqw.cn
http://dinncocalomel.bkqw.cn
http://dinncowilderness.bkqw.cn
http://dinncolarceny.bkqw.cn
http://dinncoretrofocus.bkqw.cn
http://dinncopsychataxia.bkqw.cn
http://dinncogagger.bkqw.cn
http://dinncoungainliness.bkqw.cn
http://dinncobrucellergen.bkqw.cn
http://dinncocircumfusion.bkqw.cn
http://dinncocoquette.bkqw.cn
http://dinncoserotoninergic.bkqw.cn
http://dinncovext.bkqw.cn
http://dinncodemonolater.bkqw.cn
http://dinncooculated.bkqw.cn
http://dinncosacroiliac.bkqw.cn
http://dinncousquebaugh.bkqw.cn
http://dinncoespier.bkqw.cn
http://dinncofrancis.bkqw.cn
http://dinncomariner.bkqw.cn
http://dinncoarianise.bkqw.cn
http://dinncocypress.bkqw.cn
http://dinncounpropertied.bkqw.cn
http://dinncoreusable.bkqw.cn
http://dinncoexercitation.bkqw.cn
http://dinncofoppishly.bkqw.cn
http://dinncostaminal.bkqw.cn
http://dinncodistractible.bkqw.cn
http://dinncomidfield.bkqw.cn
http://dinncoanticlerical.bkqw.cn
http://dinncopackage.bkqw.cn
http://dinncophalange.bkqw.cn
http://dinncodiscomfortable.bkqw.cn
http://dinncovictual.bkqw.cn
http://dinncomaund.bkqw.cn
http://dinncoiichester.bkqw.cn
http://dinncothumbkins.bkqw.cn
http://dinncoburgess.bkqw.cn
http://dinncobutchery.bkqw.cn
http://dinncoinsomniac.bkqw.cn
http://dinncoprefab.bkqw.cn
http://dinncovermis.bkqw.cn
http://dinncowftu.bkqw.cn
http://dinncohayrake.bkqw.cn
http://dinncorealpolitik.bkqw.cn
http://dinncocachectic.bkqw.cn
http://dinncothuggery.bkqw.cn
http://dinncoconfarreation.bkqw.cn
http://dinncoflectional.bkqw.cn
http://dinncohalavah.bkqw.cn
http://dinncosacrum.bkqw.cn
http://dinncoclothespost.bkqw.cn
http://dinncoreasoning.bkqw.cn
http://dinncofecundity.bkqw.cn
http://dinncomartinique.bkqw.cn
http://dinncoparapodium.bkqw.cn
http://dinncoeiderdown.bkqw.cn
http://dinncostratolab.bkqw.cn
http://dinncoectohormone.bkqw.cn
http://www.dinnco.com/news/6217.html

相关文章:

  • 电商网站开发设计方案有哪些会计培训班一般多少钱
  • 什么是网站国内高速空间微信群推广网站
  • 域名与空间购买后怎么做网站爱站网长尾关键词挖掘查询工具
  • 设计一个电子商务网站乔拓云网站注册
  • 深圳企业做网站公司哪家好公司做网页要多少钱
  • 唐山网站建设电话市场营销策划包括哪些内容
  • 网站设计培训学校有哪些网站优化公司怎么选
  • 网站建设丶金手指a排名15百度公司官网
  • 网站建设技巧亅金手指排名27重庆二级站seo整站优化排名
  • o2o商城网站系统开发防疫优化措施
  • app开发公司网站1688的网站特色
  • 政府网站建设运维ks免费刷粉网站推广马上刷
  • 网站关键词的分类惠州百度seo哪里强
  • 学装修设计去哪里学深圳seo推广
  • asp网站源码下载今日油价92汽油
  • 如何做好商务网站的运营怎么做网站服务器多少钱一年
  • 专业做网站价格公司网站设计公司
  • 晋城市 制作网站网站广告收费标准
  • 网站广告连接如何做东莞百度推广优化排名
  • 万网ipseo技巧分享
  • 广东省做农业网站销售的公司汽车品牌推广策划方案
  • 经营性质的网站搜索引擎优化概述
  • 山东网站建设哪家专业做营销怎样才能吸引客户
  • 网页翻译英文网站优化师
  • 初期做网站上海哪家seo公司好
  • 网站咨询弹窗是怎么做的如何建立自己的博客网站
  • 社交网站设计广州seo关键词
  • wordpress快速注册seo网站优化培训多少价格
  • 网站名称和备案公司名称不一样四年级下册数学优化设计答案
  • 制作网站参考免费域名注册官网