Merge Two Sorted Sequences
Walk both lists with one pointer each.
The Merge Step
Given two sorted lists, combine them into one sorted list. This merge is the heart of merge sort and shows up everywhere. 🔗
Two Inputs, One Pointer Each
Give each list its own pointer, both starting at index 0. You will walk them forward together, never backward.
i = 0
j = 0All lessons in this course
- Two Pointers on a Sorted Array
- Find a Pair with a Given Sum
- Remove Duplicates In Place
- Merge Two Sorted Sequences