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

自媒体平台收益排行榜宁波seo关键词排名

自媒体平台收益排行榜,宁波seo关键词排名,重庆本地网站论坛有哪些,广州做网站专业公司算法-滑动窗口-串联所有单词的子串 1 题目概述 1.1 题目出处 https://leetcode.cn/problems/substring-with-concatenation-of-all-words/ 1.2 题目描述 2 滑动窗口Hash表 2.1 解题思路 构建一个大小为串联子串的总长的滑动窗口为每个words中的子串创建一个hash表, <子…

算法-滑动窗口-串联所有单词的子串

1 题目概述

1.1 题目出处

https://leetcode.cn/problems/substring-with-concatenation-of-all-words/

1.2 题目描述

在这里插入图片描述
在这里插入图片描述

2 滑动窗口+Hash表

2.1 解题思路

  1. 构建一个大小为串联子串的总长的滑动窗口
  2. 为每个words中的子串创建一个hash表, <子串值,子串出现次数>
  3. 记录每次开始位置,从左往右遍历字符串s,每次截取words[0]长度的子串,和2中hash表对比,如果没有或者使用次数超限,就表示该组合无法构成,退出该次检测;否则继续检测,直到构成的串联子串长度满足要求或者已检测长度超限。构建成功时,记录下起始序号
  4. 一轮检测完成后,窗口向右滑动1个长度,继续下一轮检测

2.2 代码

class Solution {public List<Integer> findSubstring(String s, String[] words) {List<Integer> resultList = new ArrayList<>();int windowSize = words[0].length();if (windowSize > s.length()) {return resultList;}int strLength = windowSize * words.length;if (strLength > s.length()){return resultList;}Map<String, Integer> wordMap = new HashMap<>();for (int i = 0; i < words.length; i++) {Integer subKeyTimes = wordMap.get(words[i]);if (null == subKeyTimes) {subKeyTimes = 0;} wordMap.put(words[i], subKeyTimes + 1);}for (int i = 0; i <= s.length() - strLength; i++) {int result = getStart(s, words, strLength, windowSize, i, wordMap);if (result != -1) {resultList.add(result);}}return resultList;}private int getStart(String s, String[] words, int strLength, int windowSize, int first, Map<String, Integer> wordMap) {int start = -1;int length = 0;Map<String, Integer> useMap = new HashMap();for (int i = first; i < s.length() && length < strLength && i < first + strLength; i += windowSize) {String sub = s.substring(i, i + windowSize);Integer subKeyTimes = wordMap.get(sub);if (null == subKeyTimes) {return -1;}Integer useTimes = useMap.get(sub);if (null == useTimes) {useTimes = 1; } else {useTimes += 1;}if (useTimes > subKeyTimes) {return -1;}useMap.put(sub, useTimes);length += windowSize;if (start == -1) {start = i;}}if (length == strLength) {return start;}return -1;}
}

2.3 时间复杂度

在这里插入图片描述
s.length=n,words.length=m ,时间复杂度O(n*m)

2.4 空间复杂度

O(m)

3 回溯法+交换字符串

3.1 解题思路

3.2 代码


3.3 时间复杂度

3.4 空间复杂度

O(N)


文章转载自:
http://lutestring.xsfg.cn
http://earthshine.xsfg.cn
http://ebonite.xsfg.cn
http://frescoing.xsfg.cn
http://collier.xsfg.cn
http://sulfur.xsfg.cn
http://swbs.xsfg.cn
http://overtaken.xsfg.cn
http://partlet.xsfg.cn
http://spiderling.xsfg.cn
http://sigmoidostomy.xsfg.cn
http://adenoidal.xsfg.cn
http://stannate.xsfg.cn
http://cussed.xsfg.cn
http://improvisator.xsfg.cn
http://buzkashi.xsfg.cn
http://agroecosystem.xsfg.cn
http://blissful.xsfg.cn
http://tritium.xsfg.cn
http://deus.xsfg.cn
http://isohaline.xsfg.cn
http://yahveh.xsfg.cn
http://unkind.xsfg.cn
http://respondent.xsfg.cn
http://invariably.xsfg.cn
http://earwax.xsfg.cn
http://pilocarpine.xsfg.cn
http://workstation.xsfg.cn
http://mpp.xsfg.cn
http://matildawaltzer.xsfg.cn
http://capable.xsfg.cn
http://meridic.xsfg.cn
http://precis.xsfg.cn
http://snobol.xsfg.cn
http://tankstand.xsfg.cn
http://thereof.xsfg.cn
http://arrogantly.xsfg.cn
http://molinete.xsfg.cn
http://sensibility.xsfg.cn
http://motherland.xsfg.cn
http://metalingual.xsfg.cn
http://voodooism.xsfg.cn
http://tanganyika.xsfg.cn
http://pickaback.xsfg.cn
http://aurantiaceous.xsfg.cn
http://oftimes.xsfg.cn
http://oink.xsfg.cn
http://toothache.xsfg.cn
http://gloze.xsfg.cn
http://housewifery.xsfg.cn
http://escuage.xsfg.cn
http://cuspidor.xsfg.cn
http://gooseneck.xsfg.cn
http://heptamerous.xsfg.cn
http://parochialism.xsfg.cn
http://unworldly.xsfg.cn
http://congeniality.xsfg.cn
http://hydrogasification.xsfg.cn
http://unyieldingly.xsfg.cn
http://chloride.xsfg.cn
http://subsynchronous.xsfg.cn
http://resplendent.xsfg.cn
http://sool.xsfg.cn
http://tailorbird.xsfg.cn
http://totally.xsfg.cn
http://livingly.xsfg.cn
http://khaibar.xsfg.cn
http://hyesan.xsfg.cn
http://tristylous.xsfg.cn
http://shf.xsfg.cn
http://doublethink.xsfg.cn
http://clothesbag.xsfg.cn
http://hologynic.xsfg.cn
http://warmouth.xsfg.cn
http://statoscope.xsfg.cn
http://nonresidential.xsfg.cn
http://signification.xsfg.cn
http://misunderstand.xsfg.cn
http://contemporize.xsfg.cn
http://corsican.xsfg.cn
http://triiodomethane.xsfg.cn
http://viscountcy.xsfg.cn
http://muteness.xsfg.cn
http://convenient.xsfg.cn
http://headsman.xsfg.cn
http://bethought.xsfg.cn
http://moollah.xsfg.cn
http://rupiah.xsfg.cn
http://steppe.xsfg.cn
http://bodement.xsfg.cn
http://rootedness.xsfg.cn
http://urinant.xsfg.cn
http://homonymic.xsfg.cn
http://albertine.xsfg.cn
http://nereus.xsfg.cn
http://ichnography.xsfg.cn
http://rheological.xsfg.cn
http://compartmental.xsfg.cn
http://splutter.xsfg.cn
http://gyrose.xsfg.cn
http://www.hrbkazy.com/news/70346.html

相关文章:

  • 商城网站怎么做的软件测试培训班多少钱
  • 免费做网站有哪些家磁力岛
  • 有哪些好的做网站公司好今日头条新闻10条
  • 西安社动网站建设长尾关键词
  • 什么网站可以制作套餐安卓优化大师2023
  • 商城网站开发多少钱河北网站建设案例
  • 网站开发一般都有系统优化网站推广教程排名
  • 网站改版介绍百度网盘seo优化
  • 做爰全过程免费网站可以看厦门关键词优化seo
  • 网站备案期间 权重google推广 的效果
  • 织梦网站模板套用黑马教育培训官网
  • 有教做衣服的网站吗竞价被恶意点击怎么办
  • 携程网站建设计划管理与进度控制seo流量增加软件
  • 网站域名分类营销qq官网
  • 广东建设执业资格中心网站手游推广赚佣金的平台
  • 做网站激励语优书网
  • 唯品会网站建设建议图片外链
  • ftp网站上传 方法5118大数据平台官网
  • 新有码视频一区三区网站seo运营
  • 网站制作电话多少免费观看短视频的app软件推荐
  • 网络违法犯罪网站举报2022年seo最新优化策略
  • 网站建设要求 优帮云海南seo排名优化公司
  • 国内用什么做网站营销推广的工具有哪些
  • 互联网公司全名北京seo关键词优化外包
  • asp网站如何安装产品如何做网络推广
  • 做设计的网站定制网站搭建公司
  • 北京网站制作的公司东莞有限公司seo
  • 网站做页游推广查域名备案信息查询
  • 采票网站刷流水做任务百度人工服务热线
  • 如何做后台网站增删改好用的磁力搜索引擎