Optimal Algorithmic Approach
Fixed-size sliding window with frequency diff counter.
Core Invariants & Edge Cases
- Fixed window of size len(P) with character frequency comparison
- Slide the window, adding new char and removing old char
- Use a 'matches' counter to avoid full-array comparison each step