Find every anagram window of a pattern
Asked at Jane Street, Akuna Capital
Given a text and a shorter pattern, find every start index in the text where a window of the pattern's length is an anagram of the pattern, the same characters with the same multiplicities, in any order.
text = "cbaebabacd", pattern = "abc"
-> [0, 6] # "cba" and "bac" are anagrams of "abc"
Return all such start indices. Aim for .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.