GoalScope — find_all_anagrams (Qwen2.5-Coder-32B-Instruct) — hover a token to see the patched verbalization
↵
<code>↵
def find_all_anagrams(s, p):↵
"""Find all start indices of anagrams of p in s."""↵
from collections import Counter↵
p_count = Counter(p)↵
s_count = Counter()↵
result = []↵
p_len = len(p)↵
↵
for i in range(len(s)):↵
s_count[s[i]] += 1↵
if i >= p_len:↵
if s_count[s[i - p_len]] == 1:↵
del s_count[s[i - p_len]]↵
else:↵
s_count[s[i - p_len]] -= 1↵
if s_count == p_count:↵
result.append(i - p_len + 1)↵
↵
return result↵
</code>