public ArrayList<Integer> findSubstring(String S, String[] L) {
        res = new ArrayList<Integer>();
        if(S == null || S.length() == 0) return res;
        if(L == null || L.length == 0) return res;
        this.S = S;
        this.L = L;

        word2count = new HashMap<String, Integer>();

        for(int i = 0; i < L.length; i++){
            if(word2count.containsKey(L[i])){
                word2count.put(L[i], word2count.get(L[i]) + 1);
            } else {
                word2count.put(L[i], 1);
            }
        }

        for(int i = 0; i <= S.length() - L.length * L[0].length(); i++){
            tryNextWord(0, i);
        }

        return res;
    }