Problem Brief
Pack Items
FULLTIMEOA
An amazon fulfillment associate has a set of items that need to be packed in two boxes, given an array of item weights (arr) to be placed, divide the item weights subsets A and B for packing into associate boxes while respecting the following conditions.
The conditions:
Function Description
Complete the function packItems in the editor.
packItems has the following parameter:
int[] arr: an array of integers representing item weights
Returns
int[]: an array of integers representing the weights of items in subset A
1Example 1
Input
arr = [3, 7, 5, 6, 2]
Output
[6, 7]
Explanation
Subset A = [6, 7] and Subset B = [3, 5, 2]. The intersection of A and B is null, the union equals the original array, A is minimal in size, and the sum of A's weights (13) is greater than the sum of B's weights (10).
2Example 2
Input
arr = [4, 5, 2, 3, 1, 2]
Output
[4, 5]
Explanation
Subset A = [4, 5] and Subset B = [2, 3, 1, 2]. The intersection of A and B is null, the union equals the original array, A is minimal in size, and the sum of A's weights (9) is greater than the sum of B's weights (8).
3Example 3
Input
arr = [1, 2, 2, 2, 3, 4]
Output
[1, 3, 4]
Explanation
🥲
4Example 4
Input
arr = [2, 2, 2, 3]
Output
[2, 2, 2]
Explanation
🥲
5Example 5
Input
arr = [1,1,1,1,4,4,4,7,8]
Output
[4,4,4,8]
Explanation
🥲