Skip to content

Instantly share code, notes, and snippets.

@ibreathebsb
Last active October 6, 2018 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibreathebsb/17bdc54d0f527d477520a0ae9bc50b49 to your computer and use it in GitHub Desktop.
Save ibreathebsb/17bdc54d0f527d477520a0ae9bc50b49 to your computer and use it in GitHub Desktop.
LeetCode 26. Remove Duplicates from Sorted Array
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