@@ -0,0 +1,1588 @@
+// 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.%0A%0A// For example, given:%0A// S: %22barfoothefoobarman%22%0A// L: %5B%22foo%22, %22bar%22%5D%0A%0A// You should return the indices: %5B0,9%5D.%0A// (order does not matter).%0A%0Apublic class Solution %7B%0A    public List%3CInteger%3E findSubstring(String S, String%5B%5D L) %7B%0A        List%3CInteger%3E list = new ArrayList%3CInteger%3E();%0A        int wordsNum = L.length;%0A        if(wordsNum == 0) return list;%0A%0A        int sLen = S.length();%0A        int wordLen = L%5B0%5D.length();%0A        int window = wordLen * wordsNum;%0A        if(sLen %3C window) return list;%0A        HashMap%3CString, Integer%3E map = new HashMap%3CString, Integer%3E();%0A%0A        for(String s : L)%7B%0A        %09map.put(s, map.containsKey(s)? map.get(s) + 1 : 1);%0A        %7D %0A%0A        for(int i = 0; i %3C= (sLen - window); i++)%7B%0A        %09String tempString = S.substring(i, i + window);%0A        %09int matched = 0;%0A        %09HashMap%3CString, Integer%3E mapCopy = new HashMap%3CString, Integer%3E(map);%0A        %09for(int j = 0; j %3C tempString.length(); j += wordLen)%7B%0A        %09%09String substring = tempString.substring(j, j + wordLen);%0A        %09%09if(mapCopy.containsKey(substring))%7B%0A        %09%09%09if(mapCopy.get(substring) %3C 1)%7B%0A        %09%09%09%09break;%0A        %09%09%09%7D%0A        %09%09%09mapCopy.put(substring, mapCopy.get(substring) - 1);%0A        %09%09%09matched++;%0A        %09%09%7D%0A        %09%7D%0A%0A        %09if(matched == wordsNum)%7B%0A        %09%09list.add(i);%0A        %09%7D%0A        %7D%0A%0A        return list;%0A    %7D%0A%7D

add substring with concatenation of all words solution