Approach Summary
Track the count of the most frequent character in the window. If window_size - max_count > k, shrink the window from the left.
How to Recognize This Pattern
- Replace at most k characters
- Longest uniform substring
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(1)
Tags
String Sliding Window