Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

remove duplicates from sorted array

def remove_duplicates(nums: [int]) -> int:
    cnt = 1
    for index in range(len(nums) - 1):
        if nums[index] != nums[index + 1]:
            nums[cnt] = nums[index + 1]
            cnt += 1
    print(cnt)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #remove #duplicates #sorted #array
ADD COMMENT
Topic
Name
5+9 =