You are given an integer array nums of length n.
You need to distribute all elements of nums into two arrays, arr1 and arr2, using the following process:
Append nums[0] to arr1.
Append nums[1] to arr2.
For each subsequent element nums[i] from index
Let greaterCount(arr, val) be the number of elements in arr that are strictly greater than val.
If greaterCount(arr1, nums[i]) > greaterCount(arr2, nums[i]), append nums[i] to arr1.
If greaterCount(arr1, nums[i]) < greaterCount(arr2, nums[i]), append nums[i] to arr2.
If greaterCount(arr1, nums[i]) == greaterCount(arr2, nums[i]), append nums[i] to the array with the smaller length. If both arrays have the same length, append nums[i] to arr1.
Return the array formed by concatenating arr1 and arr2.
Constraints:
nums[i]
You are given an integer array nums of length n.
You need to distribute all elements of nums into two arrays, arr1 and arr2, using the following process:
Append nums[0] to arr1.
Append nums[1] to arr2.
For each subsequent element nums[i] from index
Let greaterCount(arr, val) be the number of elements in arr that are strictly greater than val.
If greaterCount(arr1, nums[i]) > greaterCount(arr2, nums[i]), append nums[i] to arr1.
If greaterCount(arr1, nums[i]) < greaterCount(arr2, nums[i]), append nums[i] to arr2.
If greaterCount(arr1, nums[i]) == greaterCount(arr2, nums[i]), append nums[i] to the array with the smaller length. If both arrays have the same length, append nums[i] to arr1.
Return the array formed by concatenating arr1 and arr2.
Constraints:
nums[i]