Created
September 18, 2018 16:03
-
-
Save frankchang0125/e57064a2348860b8f755caec44bba4a4 to your computer and use it in GitHub Desktop.
27. Remove Element
This file contains 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 removeElement(nums []int, val int) int { | |
n := 0 | |
for i, num := range nums { | |
if num != val { | |
nums[n] = nums[i] | |
n++ | |
} | |
} | |
return n | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment