Approach Summary
Use a fixed-size window equal to s1.length. Compare character frequency maps of the window and s1.
How to Recognize This Pattern
- Fixed window = length of pattern
- Check if window is anagram
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(1)
Tags
String Hash Map Sliding Window