双指针
class Solution {
public:
vector<int> findSubstring(string s, vector<string>& words) {
if(s==""||!words.size()) return vector<int>();
unordered_map<string,int> mp,cnt_mp;
int wn=words.size(),wl=words[0].size();
for(int i=0;i<wn;i++)
mp[words[i]]++;
vector<int> res,vis(s.size(),0);
for(int i=0;i<s.size();++i){
if(vis[i]) continue;
cnt_mp.clear();
for(int j=0,k=0,f=0;j<((int)s.size()-i)/wl-wn+1;j++){
vis[i+j*wl]=1;
string sub_str;
while(k-j<wn){
sub_str=s.substr(i+k*wl,wl);
cnt_mp[sub_str]++;
if(!mp.count(sub_str)||cnt_mp[sub_str]>mp[sub_str]) f++;
k++;
}
if(f==0) res.push_back(i+j*wl);
sub_str=s.substr(i+j*wl,wl);
if(!mp.count(sub_str)||cnt_mp[sub_str]>mp[sub_str]) f--;
cnt_mp[sub_str]--;
}
}
return res;
}
};