Remove duplicates from sorted array Problem
Remove duplicates from sorted array Problem — ExecCode Medium DSA Practice
Solve the Remove duplicates from sorted array problem on ExecCode. Free online medium DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a sorted array, remove duplicate values in place and return the number of unique values. The write pointer marks where the next new value should be stored.
Examples
Input nums = [1,1,2]; Output 2. Input nums = [0,0,1,1,1,2,2,3,3,4]; Output 5
Constraints
1 ≤ nums.length ≤ 3×10⁴ -100 ≤ nums[i] ≤ 100 nums is sorted non-decreasing
Practice Remove duplicates from sorted array free on ExecCode. Browse DSA problems, topic map, and placement guides.