Get Maximum Sum Arr (Fungible :)
Problem Overview
- Given array item_weights of n items, remove exactly n/3 elements (keep order) to form new_arr that maximizes sum_arr = sum(first half) − sum(second half).
- Input: int array item_weights with n divisible by 3; Output: int maximum possible sum_arr.
- Constraints: 3 ≤ n ≤ 1e5; item_weights[i] in [-1e4, 1e4].
- Real-world context: optimizing packing weights at an Amazon fulfillment center.
- Asked in Amazon interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
