标签:each inf .com div caller return class not get
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Clarification:
Confused why the returned value is an integer but your answer is an array?
Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.
Internally you can think of this:
class Solution(object): def removeDuplicates(self, A): """ :type nums: List[int] :rtype: int """ if not A: return 0 newTail = 0 for i in range(1, len(A)): if A[i] != A[newTail]: newTail += 1 A[newTail] = A[i] return newTail + 1
以上
26. Remove Duplicates from Sorted Array
标签:each inf .com div caller return class not get
原文地址:https://www.cnblogs.com/jyg694234697/p/9542298.html