# @lc code=start classSolution: deffindAnagrams(self, s: str, p: str) -> List[int]: left, right = 0, 0 res = []
window = collections.defaultdict(int) needs = collections.defaultdict(int) for char in p: needs[char] += 1
match = 0 while(right < len(s)): c1 = s[right] if c1 in needs: window[c1] += 1 if window[c1] == needs[c1]: match += 1 right += 1
while match==len(needs): if right-left == len(p): res.append(left) c2 = s[left] if c2 in needs: window[c2] -= 1 if window[c2] < needs[c2]: match -= 1 left += 1