List 1:
1
2
4
5
6
8
10
List 2:
2
3
4
6
9
10
12
Intersection: []
How It Works:
- 1. Use two pointers, one for each sorted list
- 2. Compare elements at current positions
- 3. If equal, add to intersection and advance both pointers
- 4. If first element is smaller, advance first pointer
- 5. If second element is smaller, advance second pointer
- 6. Continue until one list is exhausted
Legend:
Unprocessed
Current Position
Found in Intersection