Remove Duplicates from a Sorted Array
Use two pointers: one scans the array, the other marks the end of the unique prefix.
Interactive visualization
Since the array is sorted, equal values are adjacent. So each new value only needs to be compared with the last unique value we kept.
Read pointer j
Scans every input value.
Write pointer i
Marks the last unique value.