添加Go语言题解

This commit is contained in:
zouxinyao
2021-07-28 02:26:32 +08:00
parent 7eb8b4a9fd
commit 575b7612f0
52 changed files with 1679 additions and 104 deletions

View File

@@ -182,3 +182,25 @@ class Solution {
}
}
```
Go Code:
```go
func removeElement(nums []int, val int) int {
length := len(nums)
if length == 0 {
return 0
}
i := 0
for j := 0; j < length; j++ {
if nums[j] == val {
continue
}
nums[i] = nums[j]
i++
}
return i
}
```