Question
Given a text and a query, find the first position at which a substring of the text is an anagram of the query. Two strings are anagrams when they contain the same characters with the same multiplicities, regardless of order. ## Requirements Implement: ```python def anagram_index(lookup_string: str, query: str) -> int: ... ``` Return the zero-based start index of the first matching window, or `-1` when no match exists. An empty query matches at index `0`; a query longer than the text has no match. Characters are initially compared exactly, including case. Aim for `O(n + m)` time for a text of length `n` and query of length `m`, rather than sorting every window. ## Additional assessed interfaces ```python def find_all_anagram_indices(lookup_string: str, query: str) -> list[int]: ... def anagram_index_ignore_case(lookup_string: str, query: str) -> int: ... def first_anagram_each(lookup_string: str, queries: list[str]) -> list[int]: ... ``` 1. Return every matching start index. For an empty query, return every boundary from `0` through `len(lookup_string)`. 2. Add case-insensitive matching by applying Python `str.lower()` to both strings, returning an index in the normalized text. Unicode lowercase expansion may change index positions; no original-text offset mapping is required. 3. Given many queries, return the first match for each and discuss when preprocessing the text is worthwhile. All four functions are checked. Results for all matches must be in ascending order, including overlapping windows. The multi-query result preserves query order. The provided fixture adapter selects only these four interfaces. ## Design discussion (not graded) Explain how your design changes for original-offset Unicode normalization or streaming input.