Advertisement
smj007

Untitled

Mar 9th, 2025
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. class Solution:
  2.     def removeDuplicates(self, nums: List[int]) -> int:
  3.        
  4.         # since the array is already sorted we can get away by not using a map
  5.         # also a blunder was made where the unique_tracker was started from 0
  6.         # since it followed a particular pattern that you did in the last question
  7.         unique_tracker = 1
  8.         for i in range(1, len(nums)):
  9.             if nums[i] != nums[i-1]:
  10.                 nums[unique_tracker] = nums[i]
  11.                 unique_tracker += 1
  12.                
  13.         return unique_tracker
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement