You are given a nums of length n containing distinct elements.
You need to distribute all elements of nums into two arrays, arr1 and arr2, across n operations:
In the first operation, append nums[1] to arr1.
In the second operation, append nums[2] to arr2.
For each subsequent n:
If the last element of arr1 is greater than the last element of arr2, append nums[i] to arr1.
Otherwise, append nums[i] to arr2.
Return the array formed by concatenating arr1 and arr2.
Constraints:
n
nums[i]
All elements in nums are distinct.
You are given a nums of length n containing distinct elements.
You need to distribute all elements of nums into two arrays, arr1 and arr2, across n operations:
In the first operation, append nums[1] to arr1.
In the second operation, append nums[2] to arr2.
For each subsequent n:
If the last element of arr1 is greater than the last element of arr2, append nums[i] to arr1.
Otherwise, append nums[i] to arr2.
Return the array formed by concatenating arr1 and arr2.
Constraints:
n
nums[i]
All elements in nums are distinct.