Last active
October 6, 2018 02:51
-
-
Save ibreathebsb/17bdc54d0f527d477520a0ae9bc50b49 to your computer and use it in GitHub Desktop.
LeetCode 26. Remove Duplicates from Sorted Array
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
func removeDuplicates(nums []int) int { | |
start := 0 | |
current := 1 | |
for current < len(nums) { | |
if nums[current] != nums[start] { | |
nums[start+1] = nums[current] | |
start++ | |
} | |
current++ | |
} | |
return start + 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment