Back to course home
0% completed
Vote For New Content
Shouldn't we need to use a while loop to see if the window has become invalid ra...
Alex
Mar 1, 2022
Shouldn't we need to use a while loop to see if the window has become invalid rather than an if statement? Consider the situation in which arr[windowStart] = 1 when we enter the if statement. In that case, we'll decrement maxOnesCount and also increment windowStart. This means that when we leave the if statement, we will still have an invalid window (i.e. windowEnd - windowStart + 1 - maxOnesCount will still be greater than k).
1
0
Comments
Comments
Design Gurus4 years ago
Can you specify an input where you think the given solution will go wrong?
On this page