DSAverse
Two Pointers & Sliding Window
Loading Two Pointers...
Two Sum Pattern
2 + 6 = 82
7
11
15
1
8
3
9
4
6
L=0target: 10R=9
Initializing Sorting Algorithms...
Sorting
Trees
Graphs
Preparing interactive visualizations...
Two Pointers & Sliding Window
Loading Two Pointers...
Two Sum Pattern
2 + 6 = 8Slide a fixed-size window of length k across the array. Update the sum in O(1) per step by removing the outgoing element and adding the incoming one.
Window [0..2] = [2, 1, 5]
Ready — press Play or step through.
Question 1 of 3
Why is the sliding window approach O(n) instead of O(n*k)?