Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
Added RemoveDuplicates.py (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brkgng authored Oct 5, 2021
1 parent c1f8161 commit a7cf50e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Programming/Python/RemoveDuplicates/RemoveDuplicates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Given an integer array nums(sorted in non-decreasing order),
# remove the duplicates in nums. The relative order of the elemntes is same.
def removeDuplicates(nums):
k = 0
for i in range(1, len(nums)):
if nums[k] != nums[i]:
k += 1
nums[k] = nums[i]
# Return final result length and array
return k+1, nums

0 comments on commit a7cf50e

Please sign in to comment.