# LC5585 Substring with Concatenation of All Words **Idea.** Fixed-size word windows. ```python from collections import Counter def findSubstring(s,words): if not words: return [] w=len(words[0]); n=len(words); need=Counter(words); res=[] for i in range(w): l=i; win=Counter(); cnt=0 for j in range(i,len(s)-w+1,w): word=s[j:j+w]; win[word]+=1; cnt+=1 while win[word]>need[word]: left=s[l:l+w]; win[left]-=1; l+=w; cnt-=1 if cnt==n: res.append(l) return res ``` **Interview habit.** Say the brute force, then the optimisation, then edge cases. Rehearse that flow with [learn more](https://www.linkjob.ai/) (https://www.linkjob.ai/).