Get Minimal Cost
Learn this problemProblem statement
Howdy, amazing user friends! This problem was identified as a duplicate of Selling Shoes. However, after serious consideration, I decided not to merge duplicates for now as both of them have received code submissions. I will figure an approach to handle a situation like this in the future. Thank you for your understanding! All your hard working will eventually be rewarded in a way you expect! 🧡
An online retailer offers products in n different dimensions as specified in the array dimensions. The category supervisor notices that several dimensions are redundant and do not offer a favorable customer experience. To optimize the available stock, the product should be offered in unique dimensions. The dimension of the i-th product, dimensions[i], can be augmented by one unit for a fee given in the adjustmentCosts array, adjustmentCosts[i].
Determine the minimal total fee required to ensure that all product dimensions are unique.
Function
getMinimalCost(dimensions: int[], adjustmentCosts: int[]) → longExamples
Example 1
dimensions = [3, 7, 9, 7, 8]adjustmentCosts = [5, 2, 5, 7, 5]return = 6Example 2
dimensions = [3, 3, 4, 5]adjustmentCosts = [5, 2, 2, 1]return = 5Example 3
dimensions = [2, 3, 3, 2]adjustmentCosts = [2, 4, 5, 1]return = 7Constraints
1 ≤ n ≤ 2 * 10^51 ≤ size[i] ≤ 10^91 ≤ cost[i] ≤ 10^4
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026