# Leetcode 26. Remove Duplicates from Sorted Array # 題解 ## 雙指針  ```python! class Solution: def removeDuplicates(self, nums: List[int]) -> int: n = len(nums) i = j = 1 while j < n: if nums[j] != nums[j-1]: # 找不不同 i 再走 nums[i] = nums[j] i += 1 j += 1 # 持續找不同 return i # 最後 i 會在邊界上 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up