Arrays & Strings II
- Set membership → duplicates in O(n)
- Two pointers → stable element movement
- Sliding window → longest unique substring
- Stack → validate parentheses
- Monotonic stack → next warmer day
- Monotonic deque → sliding window maximum
- Binary search → insertion position
- Sort + sweep → merge intervals
1 / 7
Two pointers
- Track write index for non‑zero elements
- Fill remaining with zeros
2 / 7
Sliding window
- Maintain a map of last‑seen indices
- Move left pointer when you see duplicates
3 / 7
Monotonic stack
- Stack holds indices with decreasing values
- Pop while current is greater
4 / 7
Monotonic deque
- Deque stores candidate indices
- Front is always the window max
- Pop back while smaller than current
5 / 7
Binary search
- Maintain low/high bounds
- Answer is low after the loop
6 / 7
Sort + sweep
- Sort intervals by start
- Merge when next.start <= current.end
7 / 7
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.