gary@interview:~/interview/coding/26-remove-duplic….md$
$ cat ./coding/26-remove-duplicates-from-sorted-array.md
[Coding]

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

--tags#Two Pointers
$ ls ./coding/ | grep -v 26-remove-duplicates-from-sorted-array
265. Paint House II256. Paint House143. Reorder List1762. Buildings With an Ocean View
← cd ../codingcd ~