1nums = [2, 1, 4, 3]
2target = 7
3left, total, best = 0, 0, 99
4for right in range(4):
5 total = total + nums[right]
6 while total >= target:
7 best = min(best, right - left + 1)
8 total = total - nums[left]
9 left = left + 1
10print("smallest window =", best)
●Your numbers are [2, 1, 4, 3] and your target is 7. We want the SHORTEST run of neighbours adding up to at least 7.
Press play and watch the window work on the numbers you chose. Change them afterwards and see how the story changes.
📦 Memory boxes
what the program is remembering right now
nothing remembered yet🖥️ What the computer shows
the answers the program prints out
nothing yet ▌