class Solution: # @param S, a string # @param L, a list of string # @return a list of integer def findSubstring(self, S, L): n,m,w=len(S),len(L),len(L[0]) rst=[] for index in xrange(n-m*w+1): seg=[S[i:i+w] for i in xrange(index,index+m*w,w)] for item in L: if item in seg: seg.remove(item) else: break if seg==[]:rst.append(index) return rst
Friday, September 19, 2014
Leetcode: Substring with Concatenation of All Words @Python
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment