26. Remove Duplicates from Sorted Array
Problem
Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Example:
Related Topics:
Array
Two Pointers
Analysis
设置两个指标,一前一后:
当重复时,前动,后不动。
不重复时,前后都动,并且更新后指标的值。
Code
Last updated