Cant Wrap my head around the Logic

In the Solution for this problem,

In Line 14 why are we checking if we crosses the extra 0’s limit using if and not a while loop ?

If we have encountered, more 0’s than the k then shouldn’t we be increasing the start until we have reduced the 0’s count under k by using a while loop ?


The top comment on this Leetcode post really helped me understand this same question on the previous problem (it applies to this one as well):

1 Like