Leetcode 26: Remove Duplicates from Sorted Array
2 min readApr 22, 2024
In this exercise, we have a sorted array nums, and we want to update it so that there is no duplicate anymore in-place, and we return the new length of the array. Once again, we first solve the problem without considering the in-place part and at the end figure out how to make it in-place.
a. Basics of removing duplicates
At the core removing duplicates is a 2-steps process of detecting each duplicate and removing it. So if we have a data structure that allows removal of elements such as a List, we…