26. Remove Duplicates from Sorted Array
26. Remove Duplicates from Sorted Array
題目的標題寫的並不是很清楚,這個題目其實是要把
雙指針問題
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
slow = 0
fast = 0
while fast < len(nums):
if nums[fast] != nums[slow]:
slow += 1
nums[slow] = nums[fast]
fast += 1
return slow + 1