➜ ~

Playing Hacks and Stuffs!


Project maintained by h4ckyou Hosted on GitHub Pages — Theme by mattgraham

Remove Duplicates from Sorted Array

image image

I was writing the solution to this but my firefox crashed and I didn’t save the commit yet lol

To rewrite that is stressfull so I’ll just drop the solve script

But basically this involves Removing Duplicate from a Sorted Array using In-Place Algorithm

Here’s my solve script: link image

Leetcode Submission Script

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