Extra rep
Combination Rep~11 min

Hidden anagram

pattern and s are strings of lowercase letters. Write has_anagram(pattern, s): return True if some substring of s with length len(pattern) uses exactly the same letters as pattern (same counts, any order). If pattern is longer than s, return False.

has_anagram("ab", "eidbaooo") → True ("ba")

Slide a fixed window with a count dict; compare dicts with ==.

Building toward · LC 3 · Longest Substring Without Repeating CharactersNeetCode on YouTube. Watch the explanation, pause when the code starts, write it yourself here, then finish the video to compare.
main.pypracticePython