class Solution { public: vector<int> findSubstring(string S, vector<string> &L) { vector<int>v; if(L.size()==0)return v; int length=L[0].size(); map<string,int>m; for(int i=0;i<L.size();i++) m[L[i]]++; map<string,int>m1; for(int i=0;i+L.size()*length<=S.size();i++) { m1.clear(); map<string,int>::iterator it; int j,k; for(j=i,k=0;k<L.size();j=j+length,k++) { string comp=S.substr(j,length); it=m.find(comp); if(it==m.end()) break; m1[comp]++; if(m1[comp]>m[comp])break; } if(k==L.size()) { v.push_back(i); } } return v; } };