update 26
This commit is contained in:
parent
cefd877d93
commit
86ede65962
@ -1,13 +1,16 @@
|
|||||||
# Remove Duplicates from Sorted Array
|
# Remove Duplicates from Sorted Array
|
||||||
# -100 <= nums[i] <= 100
|
# -100 <= nums[i] <= 100
|
||||||
|
|
||||||
|
|
||||||
class Solution:
|
class Solution:
|
||||||
def removeDuplicates(self, nums: list[int]) -> int:
|
def removeDuplicates(self, nums: list[int]) -> int:
|
||||||
count = 0
|
count = 0
|
||||||
tmp_num = -999
|
tmp_num = -999
|
||||||
for num in nums:
|
for number_index, number in enumerate(nums):
|
||||||
if num == tmp_num:
|
if number == tmp_num:
|
||||||
|
nums.pop(number_index)
|
||||||
continue
|
continue
|
||||||
count += 1
|
count += 1
|
||||||
tmp_num = num
|
tmp_num = nums[number_index]
|
||||||
|
|
||||||
return count
|
return count
|
||||||
|
Loading…
x
Reference in New Issue
Block a user