Leetcode Note: Go - Shuffle the Array
Shuffle the Array - LeetCode
https://leetcode.com/problems/shuffle-the-array/
- Go 言語で取り組んだメモ
回答
Straightforward Go solution - Shuffle the Array - LeetCode
https://leetcode.com/problems/shuffle-the-array/solutions/747439/straightforward-go-solution/
func shuffle(nums []int, n int) []int {
x := nums[:n]
y := nums[n:]
var retVal []int
for i := 0; i < len(x); i++ {
retVal = append(retVal, x[i]);
retVal = append(retVal, y[i]);
}
return retVal
}