[LeetCode-Eazy] Remove Element

Golang

func removeElement(nums []int, val int) int {
    r := 0
    for k,v := range nums {
        if nums[k] != val {
            nums[r] = v
            r++
        }
    }
    return r
}

和這題很類似 概念都是一樣的

[LeetCode-Easy] Remove Duplicates from Sorted Array
Understand How To Solve This Problem Using Golang And Javascript.