Company: Agoda_16nov
Difficulty: medium
Wallet Denominations Problem Description A wallet contains money in various denominations. You can modify any denomination by spending $1 to: Convert it to any value in the range [money[i]/2, 2 * money[i]] Calculate the minimum amount needed to make all denominations equal. For example, given money = [1, 2, 3, 5, 2], the operations could be: Pay $2 to convert 1 into 3 (two steps) Pay $1 to convert 2 into 3 No change for 3 Pay $1 to convert 5 into 3 Pay $1 to convert 2 into 3 Total cost: $5 Note: In this example, we can also convert all the elements of the array into a different final value of 2, instead of 3, by spending 5 dollars. However, it can be shown that for less than 5 dollars, we cannot convert them to a common value. Hence, the answer is 5. Complete the function minCost in the editor with the following parameter(s): int money[n]: the denominations in the wallet Returns int: the minimum cost to make all the elements of the array equal Examples Example 1: Input: 5 2 4 4 4 8 Out