Back to course home
0% completed
Vote For New Content
Why here using if condition to shrink the window but using while condition in th...
Lex
Feb 17, 2022
Why here using if condition to shrink the window but using while condition in the solution to Longest Substring with K Distinct Characters?
1
0
Comments
Comments
M
Mikhail Putilov4 years ago
Try to add logging to your solution, you will see that the window is only growing. Each iteration algorithm expands the window by 1. So it makes sense to shrink it by 1, there is no need to keep while loop. Take a look at my solution down below, I added comments there e...
On this page