LeetCode-30-Substring with Concatenation of All Words 暴力+Map灵活数据结构
来源:互联网 发布:js获取当前网址 编辑:程序博客网 时间:2024/06/03 20:39
class Solution(object): def findSubstring(self, s, words): """ :type s: str :type words: List[str] :rtype: List[int] """ if s=="" or words==[]:return [] wordLen=len(words[0]) Len=len(words)*wordLen if Len>len(s):return [] Map={} ans=[] for i in range(len(words)): if words[i] not in Map: Map[words[i]]=(i,1) else: Map[words[i]]=(i,Map[words[i]][1]+1) for l in range(len(s)-Len+1): cur=[0]*len(words) flag=0 for j in range(l,l+Len,wordLen): curstr=s[j:j+wordLen] if curstr not in Map: flag=1 break; v=Map[curstr][0] cur[v]+=1 if cur[v]>Map[curstr][1]: flag=1 break; if flag==0: ans.append(l) return ans
阅读全文
1 0
- LeetCode-30-Substring with Concatenation of All Words 暴力+Map灵活数据结构
- LeetCode 30 Substring with Concatenation of All Words (map)
- LeetCode: Substring with Concatenation of All Words
- LeetCode : Substring with Concatenation of All Words
- [Leetcode] Substring with Concatenation of All Words
- [LeetCode]Substring with Concatenation of All Words
- LeetCode-Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- LeetCode:Substring with Concatenation of All Words
- Leetcode: Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- leetcode Substring with Concatenation of All Words
- leetcode Substring with Concatenation of All Words
- LeetCode Substring with Concatenation of All Words
- LeetCode | Substring with Concatenation of All Words
- LeetCode - Substring with Concatenation of All Words
- Substring with Concatenation of All Words -- LeetCode
- Leetcode: Substring with Concatenation of All Words
- script无素
- JavaScript(js)
- MyBatis逆向工程
- myeclipse快捷键
- MySQL数据库的安装和配置
- LeetCode-30-Substring with Concatenation of All Words 暴力+Map灵活数据结构
- 【leetcode】160. Intersection of Two Linked Lists(Python & C++)
- 最长上升子序列(LIS)长度的O(nlogn)算法
- leetcode-13-Roman to Integer
- URI URL URN
- 异步模块模式
- Windows和Linux中的动态链接库
- java利用Condition做超时机制
- Unity3D 协程实现贪吃蛇