题目概述:
题目注意点:
- 需要排序
解题思路:
- 先排序
- 双指针移动赋值
完整代码:
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if not nums: return 0
i = 0
for j in range(1, len(nums)):
if nums[i] != nums[j]:
i += 1
nums[i] = nums[j]
return i + 1
作者:xilepeng
链接:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/solution/python3-by-xilepeng-9/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。