Construct New Array
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
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
Constraints
Limits and guarantees your solution can rely on.
1 β€ numbers.length β€ 10^5-10^9 β€ numbers[i] β€ 10^9