FunctionRacerProblemsRace

Shuffle the Array

BeginnerArraysPython, JavaScript, TypeScript, Java, C++

nums has 2 * n items, written as [x1, ..., xn, y1, ..., yn]. Return the list interleaved as [x1, y1, x2, y2, ..., xn, yn], where n is the second argument.

Example 1

nums [2,5,1,3,4,7]
n 3
returns [2,3,5,4,1,7]

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

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Arrays problems