Problem · Array

Calculate Warehouse Efficiency (Probably for Supply Chain related NG positions --Fungible-- :)

MediumAmazonNEW GRADOA
See Amazon hiring insights

The supply chain manager at one of Amazon's warehouses wants to measure the efficiency of the way parcels are shipped. The volume of each parcel is represented in the array parcelWeights. Each day, the first and last parcels in the array parcelWeights are shipped until all of them are dispatched.

The manager comes up with metrics to calculate warehouse efficiency. Each day before shipping, any parcel in the warehouse is chosen and its volume is added to the sum of total efficiency. A parcel can only be chosen once.

Given the array parcelWeights, find the maximum possible efficiency of the warehouse.

Examples
01 · Example 1
parcelWeights = [4, 4, 8, 5, 3, 2]
return = 17
Example 1 illustration
02 · Example 2
parcelWeights = [2,1,8,5,6,2,4]
return = 23
Example 2 illustration
In case 1, the order of picked parcels would produce an answer of 4 + 2 + 8 + 5 = 19, which is incorrect. The correct selection of parcels would be in scenario 2, where the answer will be 4 + 6 + 8 + 5 = 23. 🥹
Constraints
1<=n<=2x10^5 0<=parcle_weights[i]<=10^9
More Amazon problems
drafts saved locally
public int calculateWarehouseEfficiency(int[] parcelWeights) {
  // write your code here
}
parcelWeights[4, 4, 8, 5, 3, 2]
expected17
checking account