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 = 8Expand the right pointer adding characters; shrink the left pointer when a duplicate enters. The window always contains a unique-character substring.
Ready — press Play or step through.
Space is O(k) where k is the size of the character set (e.g., 26 for lowercase ASCII, 128 for full ASCII). In practice this is a small constant.
Question 1 of 3
Why do we check `char_map[s[right]] >= left` instead of just checking `s[right] in char_map`?