Given strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.
s = "cbaebabacd", p = "abc"[0, 6]s
need map from p. needed = unique chars in p.have. If have[c]==need[c] → matches++have. If was matching → matches--Same as LC567 but collect all: An anagram of p must have exactly the same char frequencies in a window of size k = p.length. We check every k-length window and collect all that match.
matches counter trick: Only 2 updates per slide — add right, remove left. Each is O(1). No full array comparison. O(1) per step.
Key difference from LC567: Don't return on first match. After recording l, the window slides naturally to the next position — the loop continues until all of s is scanned.