mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-16 03:59:18 +08:00
Update the array (Go code).
This commit is contained in:
@@ -27,8 +27,8 @@ func extend(nums []int, enlarge int) []int {
|
||||
// 初始化一个扩展长度后的数组
|
||||
res := make([]int, len(nums)+enlarge)
|
||||
// 将原数组中的所有元素复制到新数组
|
||||
for i := 0; i < len(nums); i++ {
|
||||
res[i] = nums[i]
|
||||
for i, num := range nums {
|
||||
res[i] = num
|
||||
}
|
||||
// 返回扩展后的新数组
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user