Leetcode Note: Go - Concatenation of Array

Concatenation of Array - LeetCode
https://leetcode.com/problems/concatenation-of-array/

  • Go 言語で取り組んだメモ

回答

Different Go solutions - Concatenation of Array - LeetCode
https://leetcode.com/problems/concatenation-of-array/solutions/1363702/different-go-solutions/

func getConcatenation(nums []int) []int {
	n := len(nums)
	ans := make([]int, n*2)
	for i := 0; i < n; i++ {
		ans[i], ans[i+n] = nums[i], nums[i]
	}
	return ans
}