Get Maximum Sum Arr (Fungible :)
Learn this problemProblem statement
At Amazon, the team at the fulfillment center is responsible for the packaging process. There is an array, item_weights, of n items to pack. The team needs to create a new array, new_arr, by removing exactly n/3 items from item_weights without changing the order of those remaining.
- The sum_arr of array new_arr is defined as the sum of the weights or elements in the first half of the array minus the sum of the weights in the second half of the array.
- Given n items and an array item_weights, find the maximum sum_arr possible.
Function
getMaxSumArr(item_weights: int[]) → int
Complete the function getMaxSumArr in the editor below.
getMaxSumArr has the following parameters:
int item_weights[n]: item weights
Returns
int: the maximum possible sum_arr
Examples
Example 1
item_weights = [3, 2, 1]return = 2
Example 2
item_weights = [1, 3, 4, 7, 5, 2]return = 4Constraints
N ≤ 10^5item_weights[i] ≤ 10^4n is divisible by 3More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026