Skip to content

Commit db17d4f

Browse files
author
Anwar Hossain
committed
Solved 80 no problem
1 parent ac580fb commit db17d4f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/80.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import List
2+
3+
class Solution:
4+
def removeDuplicates(self, nums: List[int]) -> int:
5+
if len(nums) <= 2:
6+
return len(nums)
7+
8+
index = 2 # Start from the third element
9+
for i in range(2, len(nums)):
10+
if nums[i] != nums[index - 2]:
11+
nums[index] = nums[i]
12+
index += 1
13+
14+
return index
15+
16+
obj = Solution()
17+
print(obj.removeDuplicates([1,1,1,2,2,3]))

0 commit comments

Comments
 (0)