Easy20 pts
Remove Duplicates from Sorted Array
Given a sorted array, remove duplicates in-place so each element appears only once. Return the new length and the modified array. Use two pointers: one for unique elements, one to scan. Example: [1,1,2] → length=2, array=[1,2,...]
Input
Line 1: n. Line 2: n space-separated sorted integers.
Output
Line 1: new length. Line 2: unique elements space-separated.
Sample
3 1 1 2
Expected
2 1 2
Loading editor…
Output
No output yet. Run your code to see results.