We’re preparing your current view and syncing the latest data.
You are given an integer array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. Shuffle the array to get the array in the form [x1,y1,x2,y2,...,xn,yn]. Return the shuffled array.
An integer array nums of length 2n.
Return the shuffled array in the form [x1,y1,x2,y2, ..., xn,yn].
1 <= n <= 500 nums.length == 2n 1 <= nums[i] <= 10^3
Example 1
Input
nums = [2,5,1,3,4,7]
Output
[2,3,5,4,1,7]
Explanation
The first half is [2,5,1] and the second half is [3,4,7]. Interleave to get [2,3,5,4,1,7].
Example 2
Input
nums = [1,2,3,4,4,3,2,1]
Output
[1,4,2,3,3,2,4,1]
Explanation
The first half is [1,2,3,4] and the second half is [4,3,2,1]. Interleave to get [1,4,2,3,3,2,4,1].