Longest substring with the same letters after replacement [Sliding Window]

Abrar Shariar
Console.log()
Published in
3 min readNov 8, 2020

This is a popular algorithmic problem that involves finding the longest substring containing the same letters after replacing a certain number of letters. The sliding window pattern is employed to solve the problem.

Try the problem on educative!

Although the solution is pretty descriptive on educative, the lack of visualization, a more step-by-step approach to the algorithm and a walkthrough with the sample I/O is what prompted me to write this post.

Abrar Shariar
Console.log()

Techie | Engineer | Coder