MCPcopy Create free account
hub / github.com/EndlessCheng/codeforces-go / createTargetArray

Function createTargetArray

leetcode/weekly/181/a/a.go:3–11  ·  view source on GitHub ↗
(nums []int, index []int)

Source from the content-addressed store, hash-verified

1package main
2
3func createTargetArray(nums []int, index []int) (ans []int) {
4 for i, v := range nums {
5 id := index[i]
6 ans = append(ans, 0)
7 copy(ans[id+1:], ans[id:])
8 ans[id] = v
9 }
10 return
11}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected