class Solution {
public:
vector<int> findSubstring(string S, vector<string> &L) {
vector<int> res;
int l_len=L[0].length();
map<string,int> word_count;//建两个map,存储L里面的string出现的次数
map<string,int> counting;
int tot_len=S.length();
int num=L.size();
for(int i=0;i<num;i++)
word_count[L[i]]++;
for(int i=0;i<=tot_len-num*l_len;i++)
{
counting.clear();
int j;
for(j=0;j<num;j++)
{
string word = S.substr(i+j*l_len,l_len);//从S里面挖出来一个l_len长的string,在map中找,并统计出现的次数
if(word_count.find(word)!=word_count.end())
counting[word]++;
else
break;
if(counting[word]>word_count[word])
break;
}
if(j==num)
res.push_back(i);
}
return res;
}
};
public:
vector<int> findSubstring(string S, vector<string> &L) {
vector<int> res;
int l_len=L[0].length();
map<string,int> word_count;//建两个map,存储L里面的string出现的次数
map<string,int> counting;
int tot_len=S.length();
int num=L.size();
for(int i=0;i<num;i++)
word_count[L[i]]++;
for(int i=0;i<=tot_len-num*l_len;i++)
{
counting.clear();
int j;
for(j=0;j<num;j++)
{
string word = S.substr(i+j*l_len,l_len);//从S里面挖出来一个l_len长的string,在map中找,并统计出现的次数
if(word_count.find(word)!=word_count.end())
counting[word]++;
else
break;
if(counting[word]>word_count[word])
break;
}
if(j==num)
res.push_back(i);
}
return res;
}
};