FastPrepFastPrep
Problem Brief

Construct New Array

OA

See the Image Source section at the very bottom of the page for the original problem statement πŸˆβ€β¬› πŸˆβ€

Once upon a time, there was an array of numbers, waiting to be transformed. The first element eagerly stepped forward, claiming its place at the beginning of a new array. But before anyone else could join, the last element leaped to the second spot, not wanting to be left behind. Then, the second element followed suit, and right after, the second-to-last element took its turn. This dance continued, with each element from the front and back of the original array taking turns to form a beautifully intertwined new array, until every number had found its place.

1Example 1

Input
numbers = [0, 4, 3, 2, 1]
Output
[0, 1, 4, 2, 3]
Explanation

Following the rules above, we get the following sequence numbers[0], numbers[4], numbers[1], numbers[3], numbers[2] which results in [0, 1, 4, 2, 3]

2Example 2

Input
numbers = [-5, 4, 0, 3, 2, 2]
Output
[-5, 2, 4, 2, 0, 3]
Explanation
πŸ“πŸ“

Constraints

Limits and guarantees your solution can rely on.

1 ≀ numbers.length ≀ 10^5
-10^9 ≀ numbers[i] ≀ 10^9
public int[] duolingoConstructNewArray(int[] numbers) {
  // write your code here
}
Input

numbers

[0, 4, 3, 2, 1]

Output

[0, 1, 4, 2, 3]

Sign in to submit your solution.