Interview question · Sliding window
Longest Repeating Character Replacement
Longest Repeating Character Replacement is a Medium question that uses the sliding window pattern. PrepKit files it under Sliding window.
PrepKit lists the title and a link. The problem statement stays on the original site.
Checking your saved items
Source content: English
Key facts
- Topic
- Sliding window
- Pattern
- sliding window
- Difficulty
- Medium
- Appears in
- Blind 75, NeetCode 150
- Website
- leetcode.com
- License
- MIT License
How to use it
- Read the problem on the original site.
- Try it on your own before you look at hints or solutions.
- Then work through a related question with the same pattern.
About the Sliding window pattern
PrepKit study notes. PrepKit editors wrote these as general advice. They are not taken from the problem or from any published solution.
- What it is
- Keeping a contiguous range over an array or string and moving its edges forward while you update a running state.
- How to recognize it
- The question asks for the longest, shortest or best contiguous subarray or substring that meets a condition.
- Common pitfalls
- Recomputing the whole window at every step, shrinking it at the wrong moment, and using it when negative values break the rule for growing and shrinking.
Pages that include this
Related questions
Common questions
Where can I practice Longest Repeating Character Replacement?
Open it on leetcode.com. PrepKit links there and does not copy the problem.
What pattern does Longest Repeating Character Replacement use?
PrepKit files it under sliding window, at Medium difficulty.