Update array.go

pull/178/head
Yudong Jin 2 years ago committed by GitHub
parent 4fb267918b
commit ae78126d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,11 +49,7 @@ func insert(nums []int, num int, index int) {
/* 删除索引 index 处元素 */
func remove(nums []int, index int) {
// 把索引 index 之后的所有元素向前移动一位
for i := index; i < len(nums); i++ {
if i+1 >= len(nums) {
nums[len(nums)-1] = 0
break
}
for i := index; i < len(nums) - 1; i++ {
nums[i] = nums[i+1]
}
}

Loading…
Cancel
Save