Grokking the Engineering Manager Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Could please describe the logic of inner while loop running only once? what is t...

Syed Hassan

Jan 13, 2022

Could please describe the logic of inner while loop running only once? what is the worst case? Dont you think at worst it can be On2?

0

0

Comments
Comments
Design Gurus
Design Gurus4 years ago

The ‘while’ loop doesn’t run once for each iteration of the ‘for’ loop. It only runs for a total of ‘n’ times for ALL the iterations of ‘for’ loop. This can also be seen from windowStart += 1; we can’t have more than ‘n’ increments in “windowStart”.