educative.io

Educative

Why to use a while loop hereto shrink the window when we can make it an if conditional?

In the algorithm presented as solution, there seems to be a while loop inside the for loop, which ultimately leads to confusion in calculation of the Big O. The test cases seems to be passing even when there is an if conditional, if there are any test cases where the while loop would be necessary let us know for the same.