Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Python/remove_duplicates_from_sorted_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Remove Duplicates from Sorted Array

class Solution(object):
def removeDuplicates(self, nums):
k = 1

for i in range(1, len(nums)):
if nums[i] != nums[i - 1]:
nums[k] = nums[i]
k += 1

return k

solution = Solution()
print(solution.removeDuplicates([1,1,2]))
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
- [Subarray Product Less Than K](Python/subarray_product_less_than_k.py)
- [Valid Parentheses](Python/valid_parentheses.py)
- [Remove Element](Python/remove_element.py)
- [Remove Duplicates from Sorted Array](Python/remove_duplicates_from_sorted_array.py)