Make Array Distinct (Selling Shoes 🩰)
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.
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
1Example 1
size array distinct as {2, 4, 3, 5} with a minimum cost of 7.2Example 2
size array distinct as {3, 10, 9, 7, 8} with a minimum cost of 6, which is 2 * (10 - 7) = 6.