Chapter 3 — Removing Duplicates from Sorted Arrays
The classic in-place dedupe problem solved with the read/write two-pointer variant.
The problem
Given a sorted array, modify it in place so that each element appears at most once and return the new length.
|
|
This is the read/write variant of two pointers — one pointer scans the input while the other tracks where to write the next unique element.
Where to next?
You’ve finished a complete worked example using the two-pointer pattern. Continue to the next course in this track to see how the same idea generalizes to sliding windows.
Saved locally to your browser.