# LC5583 Find All Anagrams in a String **Idea.** Same sliding Counter. ```python from collections import Counter def findAnagrams(s,p): need=Counter(p); n=len(p); win=Counter(s[:n]); res=[] if win==need: res.append(0) for i in range(n,len(s)): win[s[i]]+=1; win[s[i-n]]-=1 if win[s[i-n]]==0: del win[s[i-n]] if win==need: res.append(i-n+1) return res ``` **Interview habit.** Say the brute force, then the optimisation, then edge cases. Rehearse that flow with [AI help for online coding assessments](https://www.linkjob.ai/) (https://www.linkjob.ai/).