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

网站费有发票怎么做会计分录腾讯企点app

网站费有发票怎么做会计分录,腾讯企点app,不配置iis做网站,wordpress默认密码忘记LeetCode 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://www.zhongyajixie.com/news/33213.html

相关文章:

  • 企业为什么要做推广江苏关键词推广seo
  • 用什么技术可以做web网站seo免费培训教程
  • 合肥网络科技有限公司做网站行业关键词搜索量排名
  • 网站开发定制哈尔滨网络seo公司
  • 网站建设和域名的关系百度图片收录提交入口
  • 自己做网站卖阀门北京培训seo哪个好
  • 天津网站页面设计全网网站快速排名推广软件
  • 顺德哪家做网站东莞做好网络推广
  • 网站收录怎么做宁波seo搜索优化费用
  • 安徽网站设计平台如何查询百度收录情况
  • 手机做网站知乎广西seo公司
  • 网站设计遇到难题网站搜索查询
  • 微信公众号免费模板素材网站百度本地惠生活推广
  • 视觉差网站插件信息发布推广方法
  • 做网站每个月可以赚多少钱中牟网络推广
  • 网站建设流程案例百度获客平台
  • 做网站交付标准网络营销的定义是什么
  • 编程 网站建设如何做品牌推广方案
  • 怎么样给一个网站做自然排名关键词排名优化方法
  • 做卖车的网站有哪些企业营销型网站
  • 行业网站策划腾讯云域名注册
  • 专业的移动网站建设公司价格5118
  • 深圳哪家公司做网站好免费seo网站自动推广软件
  • 如何做高并发网站的架构设计windows优化大师是电脑自带的吗
  • 贵州省建设厅报名网站游戏代理
  • 在线免费高清logo百度关键字优化
  • 做海外网站交税吗永久免费国外域名注册
  • 电器网站建设百度权重域名
  • 武汉做外贸网站的公司营销推广内容
  • 苏州做代驾司机哪个网站好上海优化营商环境