class Solution {
public:
vector<int> findAnagrams(string s, string p) {
vector<int> SV(26, 0);
vector<int> PV(26, 0);
vector<int> ans;
for(auto ch : p) PV[ch - 'a']++;
for(int ii = 0; ii < s.size(); ii++) {
SV[s[ii] - 'a']++;
if(ii >= p.size() - 1) {
int jj = 0;
while(jj < 26 && SV[jj] >= PV[jj]) jj++;
if(jj == 26) ans.push_back(ii - p.size() + 1);
SV[s[ii - p.size() + 1] - 'a']--;
}
}
return ans;
}
};