You are given a string, S, and a list of words, L, that are all of the same length. 
Find all starting indices of substring(s) in S that is a concatenation of each word in L 
exactly once and without any intervening characters.

For example, given:
S: "barfoothefoobarman"
L: ["foo", "bar"]

You should return the indices: [0,9].
(order does not matter).


@@ -349,8 +349,1043 @@
 tter).%0A%0A
+class Solution:%0A    # @param S, a string%0A    # @param L, a list of string%0A    # @return a list of integer%0A    def findSubstring(self, S, L):%0A        wordnum = len(L)%0A        wordlen = len(L%5B0%5D)%0A        result = %5B%5D%0A        dic_global = %7B%7D%0A        for i in L:%0A            if i not in dic_global:%0A                dic_global%5Bi%5D = 1%0A            else:%0A                dic_global%5Bi%5D += 1%0A        %0A        for i in xrange(len(S)-wordlen*wordnum+1):  # Note: here is %22len(S)-wordlen*wordnum+1%22%0A            j = 0%0A            dict = %7B%7D%0A            while j %3C wordnum:%0A                word = S%5Bi+wordlen*j:i+wordlen*j+wordlen%5D %0A                if word not in dic_global:%0A                    break%0A                if word not in dict:%0A                    dict%5Bword%5D = 1%0A                else:%0A                    dict%5Bword%5D += 1%0A                if dict%5Bword%5D %3E dic_global%5Bword%5D:%0A                    break%0A                j += 1%0A            %0A            if j == wordnum: result.append(i) # Note: here need to add %22j == wordnum%22%0A        return result %0A

Update Substring_with_Concatenation_of_All_Words.py