Skip to content

Commit f77ac1c

Browse files
committed
remove dumplicates from sorted array
1 parent c46c1bb commit f77ac1c

File tree

1 file changed

+12
-0
lines changed
  • python/leetcode26_remove_duplicates_from_sorted_array

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def removeDuplicates(self, nums:list[int]) -> int:
3+
i, j = 0, 0
4+
if len(nums) == 0:
5+
return 0
6+
7+
for i in range(0, len(nums), 1):
8+
if nums[i] > nums[j]:
9+
j = j + 1
10+
nums[j] = nums[i]
11+
12+
return j + 1

0 commit comments

Comments
 (0)