LeetCode 26. Remove Duplicates from Sorted Array
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
count = 0
before = -1000
for i in range(len(nums)):
if nums[i] != before:
nums[count] = nums[i]
count += 1
before = nums[i]
return count
numsの中で、2つのポインタを用意。
1つはnumsの中を1つずつ見ていくポインタ
もう1つは数値を入れていく場所を示すポインタ