MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / removeDuplicates

Method removeDuplicates

Array/RemoveDuplicatesFromSortedArray.py:50–72  ·  view source on GitHub ↗

:type nums: List[int] :rtype: int

(self, nums)

Source from the content-addressed store, hash-verified

48"""
49class Solution(object):
50 def removeDuplicates(self, nums):
51 """
52 :type nums: List[int]
53 :rtype: int
54 """
55
56 if not nums:
57 return
58
59 length = len(nums)-1
60
61 one = nums[length]
62
63 remove_index = []
64
65 for i in range(length-1, -1, -1):
66 if one == nums[i]:
67 remove_index.append(i)
68 continue
69 one = nums[i]
70
71 for i in remove_index:
72 nums.pop(i)

Callers

nothing calls this directly

Calls 1

popMethod · 0.45

Tested by

no test coverage detected