BBroadcom·DSASDE-1Online Assessment
Remove Duplicates From an Array / Sorted Array
Problem
Remove duplicates in place from a sorted array and return the new length; then discuss the unsorted-array variant.
Example
[1,1,2,3,3] -> [1,2,3], length 3
Constraints
- 0 ≤ n ≤ 3 × 10^4
Approach
Two-pointer write index for sorted; hash set for unsorted. Discuss the space trade-off.
added 6 days ago