Given the array nums consisting of 2n elements in the form [x₁,x2,...,XnY1Y2,..., Yn]. Return the array in the form [x₁,
Posted: Thu Jun 02, 2022 8:15 am
Given the array nums consisting of 2n elements in the form [x₁,x2,...,XnY1Y2,..., Yn]. Return the array in the form [x₁, Y₁, X2, Y2,..., Xn, Yn]. Example 1: Input: 3 2 5 1 3 4 7 Output: 2 3 5 4 17 Explanation: Since x₁=2, X2=5, x3=1, y₁=3, y2-4, y3-7 then the answer is 2 3 5 4 17 Example 2: Input: 4 1 2 3 4 4 3 2 1 Output: 1 4 2 3 3 2 4 1 Example 3: Input: 2 1 1 2 2 Output: 1 2 1 2 Constraints: • 1 <= n <= 500 nums. length == 2n • 1 <= nums [1] <= 10^3