给定两个字符串s和p找到s中所有p的异位词的子串返回这些子串的起始索引。不考虑答案输出的顺序。示例 1:输入:s cbaebabacd, p abc输出:[0,6]解释:起始索引等于 0 的子串是 cba, 它是 abc 的异位词。 起始索引等于 6 的子串是 bac, 它是 abc 的异位词。示例 2:输入:s abab, p ab输出:[0,1,2]解释:起始索引等于 0 的子串是 ab, 它是 ab 的异位词。 起始索引等于 1 的子串是 ba, 它是 ab 的异位词。 起始索引等于 2 的子串是 ab, 它是 ab 的异位词。提示:1 s.length, p.length 3 * 104s和p仅包含小写字母class Solution { public: vectorint findAnagrams(string s, string p) { int pLenp.size(),sLens.size(); vectorint ans; if(pLensLen) return ans; int left0,right0; vectorint pCount(26,0),windowCount(26,0); for(auto c:p) pCount[c-a]; while(rightsLen) { windowCount[s[right]-a]; right; if(right-leftpLen) { if(windowCountpCount) ans.push_back(left); windowCount[s[left]-a]--; left; } } return ans; } };