LeetCode,移除排序数组中重复元素,用python
1个回答
展开全部
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
result = 1;
length = len(nums);
if length == 0:
return 0;
if length == 1:
return 1;
for i in range(1,length):
if nums[i] == nums[i - 1]:
continue;
else:
nums[result] = nums[i];
result += 1;
return result;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询