mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2025-08-05 07:11:35 +00:00
添加Go语言题解
This commit is contained in:
@@ -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
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user