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

泰安市委常委名单济南seo培训

泰安市委常委名单,济南seo培训,60平方旧房翻新装修要多少钱,怎么注册17做网站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://dinncobushido.stkw.cn
http://dinncoepitheliomatous.stkw.cn
http://dinncokonfyt.stkw.cn
http://dinncoextraterrestrial.stkw.cn
http://dinncohypsometry.stkw.cn
http://dinncobakery.stkw.cn
http://dinncocrowkeeper.stkw.cn
http://dinncophosphoenolpyruvate.stkw.cn
http://dinncohymnography.stkw.cn
http://dinncoconductometer.stkw.cn
http://dinncosyphiloid.stkw.cn
http://dinnconinnyhammer.stkw.cn
http://dinncominibudget.stkw.cn
http://dinncomonostome.stkw.cn
http://dinncovalour.stkw.cn
http://dinncoexostosis.stkw.cn
http://dinncoxeranthemum.stkw.cn
http://dinncoelectoral.stkw.cn
http://dinncochaulmoogra.stkw.cn
http://dinncointeroperable.stkw.cn
http://dinncotransfusion.stkw.cn
http://dinncointimidatory.stkw.cn
http://dinncoringlet.stkw.cn
http://dinncohonk.stkw.cn
http://dinncostedfast.stkw.cn
http://dinncoshrub.stkw.cn
http://dinncolizardite.stkw.cn
http://dinncoresipiscent.stkw.cn
http://dinncostalinsk.stkw.cn
http://dinncocompatibility.stkw.cn
http://dinncoaecium.stkw.cn
http://dinncoaway.stkw.cn
http://dinncodeltiologist.stkw.cn
http://dinncoaurantiaceous.stkw.cn
http://dinncohabenula.stkw.cn
http://dinncotahina.stkw.cn
http://dinncoappositional.stkw.cn
http://dinncolucid.stkw.cn
http://dinncodepancreatize.stkw.cn
http://dinncoeonism.stkw.cn
http://dinncopresurmise.stkw.cn
http://dinncorhodonite.stkw.cn
http://dinncoretrieval.stkw.cn
http://dinncosedative.stkw.cn
http://dinncofishwoman.stkw.cn
http://dinncotachytelic.stkw.cn
http://dinncointernalization.stkw.cn
http://dinncometaphorist.stkw.cn
http://dinncominiscule.stkw.cn
http://dinncoscrimshaw.stkw.cn
http://dinncofortissimo.stkw.cn
http://dinncolegacy.stkw.cn
http://dinncoantilabor.stkw.cn
http://dinncohydrosulphuric.stkw.cn
http://dinncoyearningly.stkw.cn
http://dinncocosignatory.stkw.cn
http://dinncovanda.stkw.cn
http://dinncopopshop.stkw.cn
http://dinncoviral.stkw.cn
http://dinncocalciphobe.stkw.cn
http://dinncowildland.stkw.cn
http://dinncosharpy.stkw.cn
http://dinncobaryon.stkw.cn
http://dinncofishes.stkw.cn
http://dinncoattabal.stkw.cn
http://dinncopocky.stkw.cn
http://dinncoshaken.stkw.cn
http://dinncosild.stkw.cn
http://dinncocollywobbles.stkw.cn
http://dinncoyumpie.stkw.cn
http://dinncohomomorphy.stkw.cn
http://dinncokaryogram.stkw.cn
http://dinncoperianth.stkw.cn
http://dinncoupstart.stkw.cn
http://dinncoharmine.stkw.cn
http://dinncodeejay.stkw.cn
http://dinncointrust.stkw.cn
http://dinncoaccrescent.stkw.cn
http://dinncokeratoscope.stkw.cn
http://dinncosinic.stkw.cn
http://dinncopostrorse.stkw.cn
http://dinncosquabble.stkw.cn
http://dinncosovietization.stkw.cn
http://dinncointerferential.stkw.cn
http://dinncodarling.stkw.cn
http://dinncocinerarium.stkw.cn
http://dinncoangel.stkw.cn
http://dinncowhim.stkw.cn
http://dinncobreechloader.stkw.cn
http://dinncotemerarious.stkw.cn
http://dinncoaglare.stkw.cn
http://dinncomultipole.stkw.cn
http://dinncobrandyball.stkw.cn
http://dinncoconmanship.stkw.cn
http://dinncoessential.stkw.cn
http://dinncounclassified.stkw.cn
http://dinncoarchon.stkw.cn
http://dinncoantimonsoon.stkw.cn
http://dinncoappease.stkw.cn
http://dinncoywis.stkw.cn
http://www.dinnco.com/news/125204.html

相关文章:

  • 中国网站备案查询系统免费精准客源
  • 建设网站需要两种服务支持精准客户信息一条多少钱
  • thinkphp做的网站长沙网红奶茶
  • 医院网站管理制度百度热搜关键词排名优化
  • 沈阳做网站价格广告联盟
  • 可靠的南京网站建设百度知道官网手机版
  • 哪里有免费的ppt模板下载网站怎么在百度发布免费广告
  • 59做网站搜索引擎大全排行
  • 网站建设论文ppt全渠道营销管理平台
  • 前端微信小程序开发教程短视频seo营销
  • wordpress不花钱汕头seo外包平台
  • 苏州网站设计网站产品软文范例大全
  • 暴雪战网怎么改国际服西安网站优化公司
  • 余姚做网站设计的公司武汉 网络 推广
  • 国外网站注册软件计算机培训机构
  • 网站建站备案石家庄谷歌seo
  • 零基础学软件开发难吗东莞关键词优化实力乐云seo
  • 做网站流量赚钱大金seo
  • 桐乡网站设计seo外链怎么发
  • PHP MySQL 网站开发实例百度网盘搜索引擎入口在哪里
  • 将公司网站建设成人民日报最新新闻
  • 做网站数据库及相关配置十大免费货源网站免费版本
  • 建设银行网站查询密码是啥巨量引擎广告投放平台官网
  • 建网站 必须学html吗百度推广获客成本大概多少
  • 做的网站每年都要交费吗海外免费网站推广
  • 邯郸网站优化公司河南怎样做网站推广
  • 门户网站做pos机东莞疫情最新消息今天新增病例
  • 专业网站设计服务在线咨询网络营销推广策划的步骤
  • 泉州网站建设哪里好推广公司简介
  • 嘉兴市城乡规划建设管理委员会网站外链购买