Longest Subarray with Sum K

Visualize the longest subarray with sum K using a sliding window. Follow the left and right pointers and see when the window expands or shrinks.

Step 0 / 13
800 ms
10
0
5
1
2
2
7
3
1
4
9
5
Window sum
0
Target K
15
Best length
0

Press Start to slide the window.