Skip to main content
mediumGrind 75

Find All Anagrams in a String

Given two strings s and p Return a list of all starting indices where a substring of s is an anagram of p Example: s = "cbaebabacd", p = "abc" => [0, 6] Example: s = "abab", p = "ab" => [0, 1, 2]

Find All Anagrams in a String is the sliding window pattern: grow, shrink, and maintain just enough state to stay linear. Interviewers love it because it reveals your stateful scanning and your edge-case discipline. The trap is updating window state in the wrong order when you expand or shrink.

Arrays & HashingStringSliding Window

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Character Frequency Matchingmedium
2Part 2

Each locked part opens in the editor once the part before it passes.

Based onLeetCode