LC 0026 [E] Remove Duplicates from Sorted Array - ALawliet/algorithms GitHub Wiki

where j represents the next non-duplicate, move all the non-dupes to the left and the dupes to the right

class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        j = 1
        for i in range(1, len(nums)):
            if nums[j-1] != nums[i]:
                nums[j] = nums[i]
                j += 1
        return j