Created
October 6, 2018 03:03
-
-
Save ibreathebsb/7e2988f1f42080c8a2590b33c85c3aa6 to your computer and use it in GitHub Desktop.
LeetCode 27. Remove Element
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 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