Shuffle the Array

Easy

nums holds 2n elements in the form [x1…xn, y1…yn]. Return them interleaved as [x1, y1, x2, y2, …].

Example 1

shuffle()
Input
nums = [2,5,1,3,4,7], n = 3
Output
[2,3,5,4,1,7]

Why

x = [2,5,1], y = [3,4,7]

Example 2

shuffle()
Input
nums = [1,2,3,4,4,3,2,1], n = 4
Output
[1,4,2,3,3,2,4,1]
Constraints
1 <= n <= 500
nums.length === 2n

Topics

Arrays

Implement shuffle in the editor and return the answer — printing it is never graded.