You are building a search feature for a data processing platform. The feature needs to find substrings that are anagrams of a given pattern, which is useful for fuzzy matching and data deduplication tasks.
Two strings are anagrams if they contain the same characters with the same frequencies, regardless of order. For example, "tad", "atd", and "dat" are all anagrams of each other.
Your task is to implement a function that finds the first occurrence of a substring in a lookup string that is an anagram of a query string.
` anagram_index('databricks', 'tad') # Returns 0
anagram_index('databricks', 'ribkc') # Returns 4
anagram_index('databricks', 'xyz') # Returns -1
`
Return the starting index of the first matching substring
If no anagram exists, return -1
Empty query should match at index 0
Use efficient sliding window technique for O(n) time complexity
Handle edge cases: empty strings, query longer than lookup string