mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-24 02:14:00 +08:00
11 lines
222 B
Go
11 lines
222 B
Go
package leetcode
|
|
|
|
func createTargetArray(nums []int, index []int) []int {
|
|
result := make([]int, len(nums))
|
|
for i, pos := range index {
|
|
copy(result[pos+1:i+1], result[pos:i])
|
|
result[pos] = nums[i]
|
|
}
|
|
return result
|
|
}
|