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]
.
class Solution {public: vector findSubstring(string S, vector&L) { vector res; int len=L[0].size()*L.size(); if (S.empty()||L.empty()||S.size() Lmap; map temp; for (int i=0;i Lmap[word]) break; } if (j==i+len) res.push_back(i); } return res; }};