Skip to content

Instantly share code, notes, and snippets.

@ibreathebsb
Created October 6, 2018 03:03
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/7e2988f1f42080c8a2590b33c85c3aa6 to your computer and use it in GitHub Desktop.
Save ibreathebsb/7e2988f1f42080c8a2590b33c85c3aa6 to your computer and use it in GitHub Desktop.
LeetCode 27. Remove Element
func removeElement(nums []int, val int) int {
start := 0
current := 0
for current < len(nums) {
if nums[current] != val {
nums[start] = nums[current]
start++
}
current++
}
return start
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment