Created
March 3, 2019 16:06
-
-
Save mylons/bd7881ef78c8d3a4c45d7d48ea33c7e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def removeDuplicates(self, nums: List[int]) -> int: | |
if len(nums) < 2: return len(nums) | |
length = 1 | |
cur = 0 | |
future = 1 | |
while future < len(nums): | |
if nums[cur] == nums[future]: | |
nums[future] = 0 | |
else: | |
cur = cur+1 | |
nums[cur] = nums[future] | |
length += 1 | |
future +=1 | |
return length | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment