Update array.md

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

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

Loading…
Cancel
Save