思路
暴力解决
code
func removeElement(nums []int, val int) int {
if nums == nil {
return 0
}
for i := 0; i < len(nums); {
if nums[i] == val {
nums = append(nums[:i], nums[i+1:]...)
i--
}
i++
}
return len(nums)
}
更多内容请移步我的repo:https://github.com/anakin/golang-leetcode