Skip to content

Commit fad5237

Browse files
Merge pull request #44 from AnwarHossainSR/dev1.0
Solved 80 no problem
2 parents 1ba01bb + 47fac9d commit fad5237

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/80.py

Lines changed: 17 additions & 0 deletions
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)