题目描述请点击查看LeetCode 题目描述
Python3 代码解答如下:
class Solution:
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
i = 0
for j in range(1, len(nums)):
if nums[j] != nums[i]:
i+=1
nums[i] = nums[j]
if len(nums) == 0:
return 0
return i+1