一、题目
二、解题思路
使用两个指针 i 和 j
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
i=0
for j in range(1,len(nums)):
if nums[i]==nums[j]:
j+=1
else:
i+=1
nums[i]=nums[j]
return i+1