This is a question from Leetcode.
Given this sorted array nums = [0,0,1,1,1,2,2,3,3,4]
I want the output to be nums = [0,1,2,3,4]
However my code...
low = nums[0] - 1
for num in nums:
if num == low:
nums.remove(num)
else:
low = num
print(nums)
...produced this output: [0,1,1,2,2,3,4]
Can anyone please shed some light on where the error is?