Algorithm visualizer
Pick an algorithm, enter your own numbers or use a preset, then step through the run. The pseudocode and the explanation follow each step.
Keep a window of k values. Each slide adds one value on the right and removes one on the left, so each slide costs O(1).
Change k from 3 to 2 on the same array. Which window wins now, and does the best sum change in the same way?
Step 1 of 8
First window a[0..2]: sum = 8. Best = 8.