Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
I was using if instead of while, wondering why my length result was wrong. I und...

Anthony DiFede

Nov 10, 2022

I was using if instead of while, wondering why my length result was wrong. I understand now why shrinking the window until the sum is less than S is important.

Image

0

0

Comments
Comments
C
CaptainKidd 3 years ago

Same issue on my end. For anyone who sees this. Just because you've shrunken the window by 1 doesn't always mean the total sum is now less than S. It's entirely possible after removing the leftmost value that there is now an even smaller window that's >= S that can be c...