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

Method removeDuplicates

Array/RemoveDuplicatesFromSortedArrayII.py:46–72  ·  view source on GitHub ↗

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

(self, nums)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

popMethod · 0.45

Tested by

no test coverage detected