Optimizing Box Weights
An Amazon Fulfillment Associate has a set of items that need to be packed into two boxes. Given an integer array of the item weights (arr) to be packed, divide the item weights into two subsets, A and B, for packing into the associated boxes, while respecting the following conditions:
Return the subset A in increasing order where the sum of A's weights is greater than the sum of B's weights. If more than one subset A exists, return the one with the maximal total weight.
Complete the function minimalHeaviestSetA in the editor below.
minimalHeaviestSetA has the following parameter(s):
int arr[]: an integer array of the weights of each item in the set
Returns
int[]: an integer array with the values of subset A
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 ≤ n ≤ 10^51 ≤ arr[i] ≤ 10^4(where0 ≤ i < n)