Pattern Recognition Drill
Medium Sliding Window
The Problem
Given strings s1 and s2, return true if s2 contains a permutation of s1 as a substring.
What approach would you use?
Think about it before scrolling down.
Fixed window of size len(s1). Compare frequency counts. O(n).
Maintain a 'matches' counter for how many of 26 chars have equal counts. O(n).
Common Trap
Don't generate all permutations — that's O(n!). The frequency count comparison is key.