Remove Element
ID: 27; Easy
Solution 1
func removeElement(nums []int, val int) int {
i := 0
for j := 0; j < len(nums); j++ {
if nums[j] != val {
nums[j], nums[i] = nums[i], nums[j]
i++
}
}
return i
}Solution 2
Last updated
Was this helpful?