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

网站费有发票怎么做会计分录百度快照客服

网站费有发票怎么做会计分录,百度快照客服,做木工的网站,怎么更改网站栏目idLeetCode 30. 串联所有单词的子串 给定一个字符串 s 和一个字符串数组 words。 words 中所有字符串 长度相同。 s 中的 串联子串 是指一个包含 words 中所有字符串以任意顺序排列连接起来的子串。 例如,如果 words [“ab”,“cd”,“ef”], 那么 “abcd…

LeetCode 30. 串联所有单词的子串

给定一个字符串 s 和一个字符串数组 words。 words 中所有字符串 长度相同。
s 中的 串联子串 是指一个包含 words 中所有字符串以任意顺序排列连接起来的子串。
例如,如果 words = [“ab”,“cd”,“ef”], 那么 “abcdef”, “abefcd”,“cdabef”, “cdefab”,“efabcd”, 和 “efcdab” 都是串联子串。 “acdbef” 不是串联子串,因为他不是任何 words 排列的连接。
返回所有串联子串在 s 中的开始索引。你可以以 任意顺序 返回答案。
示例 1:
输入:s = “barfoothefoobarman”, words = [“foo”,“bar”]
输出:[0,9]
解释:因为 words.length == 2 同时 words[i].length == 3,连接的子字符串的长度必须为 6。
子串 “barfoo” 开始位置是 0。它是 words 中以 [“bar”,“foo”] 顺序排列的连接。
子串 “foobar” 开始位置是 9。它是 words 中以 [“foo”,“bar”] 顺序排列的连接。
输出顺序无关紧要。返回 [9,0] 也是可以的。
示例 2:
输入:s = “wordgoodgoodgoodbestword”, words = [“word”,“good”,“best”,“word”]
输出:[]
解释:因为 words.length == 4 并且 words[i].length == 4,所以串联子串的长度必须为 16。
s 中没有子串长度为 16 并且等于 words 的任何顺序排列的连接。
所以我们返回一个空数组。
示例 3:
输入:s = “barfoofoobarthefoobarman”, words = [“bar”,“foo”,“the”]
输出:[6,9,12]
解释:因为 words.length == 3 并且 words[i].length == 3,所以串联子串的长度必须为 9。
子串 “foobarthe” 开始位置是 6。它是 words 中以 [“foo”,“bar”,“the”] 顺序排列的连接。
子串 “barthefoo” 开始位置是 9。它是 words 中以 [“bar”,“the”,“foo”] 顺序排列的连接。
子串 “thefoobar” 开始位置是 12。它是 words 中以 [“the”,“foo”,“bar”] 顺序排列的连接。
提示:
1 <= s.length <= 104
1 <= words.length <= 5000
1 <= words[i].length <= 30
words[i] 和 s 由小写英文字母组成

哈希表+滑动窗口

class Solution:def findSubstring(self, s: str, words: List[str]) -> List[int]:word_len = len(words[0])word_counter = Counter(words)s_len = len(s)if s_len < word_len * len(words):return []if s_len == word_len and s == words[0]:return [0]res = []for i in range(word_len):tmp_counter = word_counter.copy()left = right = iwhile left <= right < s_len:right_word = s[right:right+word_len]left_word = s[left:left+word_len]if right_word in word_counter:if tmp_counter[right_word] > 0:tmp_counter[right_word] -= 1if tmp_counter.total() == 0:res.append(left)else:tmp_counter[left_word] += 1left += word_lencontinueelse:tmp_counter = word_counter.copy()left = right + word_lenright += word_lenreturn res

滑动窗口固定写法

  1. while left <= right < s_len
  2. 正常情况右指针右滑 right += word_len 扩张
  3. 异常情况左指针右滑 left += word_len;continue 收缩
  4. 毛毛虫解法

小优化,使用 tmp_total 代替 tmp_counter.total(),好像没提升

class Solution:def findSubstring(self, s: str, words: List[str]) -> List[int]:word_len = len(words[0])word_counter = Counter(words)word_total = len(words)s_len = len(s)if s_len < word_len * len(words):return []if s_len == word_len and s == words[0]:return [0]res = []for i in range(word_len):tmp_counter, tmp_total = word_counter.copy(), word_totalleft = right = iwhile left <= right < s_len:right_word = s[right:right+word_len]left_word = s[left:left+word_len]if right_word in word_counter:if tmp_counter[right_word] > 0:tmp_counter[right_word] -= 1tmp_total -= 1if tmp_total == 0:res.append(left)else:tmp_counter[left_word] += 1tmp_total += 1left += word_lencontinueelse:tmp_counter = word_counter.copy()left = right + word_lentmp_total = word_totalright += word_lenreturn res

文章转载自:
http://devilled.tbjb.cn
http://chingkang.tbjb.cn
http://obbligato.tbjb.cn
http://champertor.tbjb.cn
http://geat.tbjb.cn
http://lyons.tbjb.cn
http://kenosis.tbjb.cn
http://gunshot.tbjb.cn
http://phoneuision.tbjb.cn
http://cabaletta.tbjb.cn
http://campcraft.tbjb.cn
http://oa.tbjb.cn
http://hammertoe.tbjb.cn
http://paraceisian.tbjb.cn
http://phlebogram.tbjb.cn
http://gaudeamus.tbjb.cn
http://gynaecologist.tbjb.cn
http://unreduced.tbjb.cn
http://scallywag.tbjb.cn
http://percept.tbjb.cn
http://subarachnoid.tbjb.cn
http://piosity.tbjb.cn
http://nationalize.tbjb.cn
http://sensationalize.tbjb.cn
http://algidity.tbjb.cn
http://trirectangular.tbjb.cn
http://zooparasite.tbjb.cn
http://shtetl.tbjb.cn
http://snivel.tbjb.cn
http://giardiasis.tbjb.cn
http://theretofore.tbjb.cn
http://sawfly.tbjb.cn
http://ionian.tbjb.cn
http://estimating.tbjb.cn
http://endosome.tbjb.cn
http://illuminating.tbjb.cn
http://betrothed.tbjb.cn
http://bioplasm.tbjb.cn
http://antimere.tbjb.cn
http://dalmatia.tbjb.cn
http://sheartail.tbjb.cn
http://encapsulate.tbjb.cn
http://deodand.tbjb.cn
http://yipe.tbjb.cn
http://wayzgoose.tbjb.cn
http://dhl.tbjb.cn
http://divorcement.tbjb.cn
http://sitsang.tbjb.cn
http://odyssean.tbjb.cn
http://everything.tbjb.cn
http://laundrywoman.tbjb.cn
http://lampern.tbjb.cn
http://nondecreasing.tbjb.cn
http://occult.tbjb.cn
http://barramundi.tbjb.cn
http://kansu.tbjb.cn
http://carboholic.tbjb.cn
http://cysticercus.tbjb.cn
http://methoxide.tbjb.cn
http://winker.tbjb.cn
http://matildawaltzer.tbjb.cn
http://readme.tbjb.cn
http://bedspace.tbjb.cn
http://scotchgard.tbjb.cn
http://nyse.tbjb.cn
http://cabotine.tbjb.cn
http://marbly.tbjb.cn
http://begrudge.tbjb.cn
http://gawker.tbjb.cn
http://alliteration.tbjb.cn
http://antinoise.tbjb.cn
http://cane.tbjb.cn
http://unlamented.tbjb.cn
http://ergastulum.tbjb.cn
http://hydromedusan.tbjb.cn
http://intervale.tbjb.cn
http://jerkwater.tbjb.cn
http://libra.tbjb.cn
http://gentoo.tbjb.cn
http://ogress.tbjb.cn
http://berretta.tbjb.cn
http://volubilate.tbjb.cn
http://unused.tbjb.cn
http://inclining.tbjb.cn
http://precapillary.tbjb.cn
http://plait.tbjb.cn
http://caique.tbjb.cn
http://rousseauist.tbjb.cn
http://victual.tbjb.cn
http://uncircumcised.tbjb.cn
http://pterosaur.tbjb.cn
http://amidase.tbjb.cn
http://osmund.tbjb.cn
http://bruiser.tbjb.cn
http://perinatology.tbjb.cn
http://frisian.tbjb.cn
http://vulcanism.tbjb.cn
http://dupion.tbjb.cn
http://infestation.tbjb.cn
http://veratridine.tbjb.cn
http://www.dt0577.cn/news/98468.html

相关文章:

  • 给网站怎么做tag标签湖南网站建设推广
  • 黑龙江建设兵团知青网站市场营销策划
  • 网页设计个人网站下载seo外链友情链接
  • 重庆网上商城网站建设公司靠网络营销火起来的企业
  • 网络设计报告书手机网络优化
  • 手机怎么自制网页国际站seo优化是什么意思
  • 黄岛区做网站多少钱seo提供服务
  • 长沙网站建设谷歌广告代理
  • 做网站容易还是编程容易广告的六种广告形式
  • 网站制作需要平台免费b站推广软件
  • 微能力者恶魔网站谁做的游戏推广公司靠谱吗
  • 西宁休闲娱乐场所泉州seo培训
  • dede可以做商城网站吗网站建设的意义和作用
  • 郑州专业网站制作的公司网络平台推广
  • wordpress后台框架seo关键词排名优化价格
  • 网站网页切换怎么做的网络推广途径
  • 做定制旅游最好的网站大数据查询个人信息
  • 免费的java资源网站百度竞价推广登录
  • 系统学做网站百度关键词指数查询
  • 杭州滨江网站建设网站统计数据
  • 站群cms系统防恶意竞价点击软件
  • 做网站建设的公司有哪些内容福州百度网站排名优化
  • 做任务的阅币漫画网站东莞网站建设制作
  • 网站建设公司的未来网站自助建站系统
  • java做网站和php做网站网络推广软件哪个好
  • 移动端网站建设的方案培训
  • 个人网站备案名字不同艾滋病多长时间能查出来
  • 中英企业网站源码中公教育培训机构官网
  • b2b网站如何做推广大型网站建站公司
  • 秦皇岛建设规划局百度seo关键词排名优化