30:00
Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn], return the array in the form [x1,y1,x2,y2,...,xn,yn].
1≤n≤5001 \leq n \leq 5001≤n≤500
nums.length==2n\text{nums.length} == 2nnums.length==2n
1≤nums[i]≤1031 \leq \text{nums}[i] \leq 10^31≤nums[i]≤103
Run code to see results.
x pile: nums[0..n-1]
y pile: nums[n..2n-1]
result: x1, y1, x2, y2, ...
0 / 6 slots filled
Cut the deck in half: the x pile is nums[0..2] and the y pile is nums[3..5]. result starts empty.
nums holds 2n numbers laid out as all the x values followed by all the y values. Return them interleaved as [x1,y1,x2,y2,...,xn,yn].