Make Array Distinct (Selling Shoes 🩰)
Learn this problemProblem statement
Howdy, dear user friends! This problem was identified as a duplicate of Get Minimal Cost. 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! Your dedication will be rewarded in ways you’ve been hoping for! 🩵
Problem Description Version No.2:
You are given two arrays size and cost of size n.
The cost will be calculated for every increment.
Your task is to make the size array distinct by incrementing any of its elements
and calculate the minimum cost to do so.
Function
makeArrayDistinct(size: int[], cost: int[]) → int
Complete the function makeArrayDistinct in the editor.
makeArrayDistinct has the following parameters:
- 1.
int[] size: an array of integers representing the sizes - 2.
int[] cost: an array of integers representing the costs
Returns
int: the minimum cost to make the size array distinct
Examples
Example 1
size = [2, 3, 3, 2]cost = [2, 4, 5, 1]return = 7size array distinct as {2, 4, 3, 5} with a minimum cost of 7.Example 2
size = [3, 7, 9, 7, 8]cost = [5, 2, 5, 7, 5]return = 6size array distinct as {3, 10, 9, 7, 8} with a minimum cost of 6, which is 2 * (10 - 7) = 6.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