Company: amazon_23april
Difficulty: medium
Amazon Financial Optimization Tool In an Amazon financial optimization tool, a user manages a sequence of coins with various denominations. The process involves systematically exchanging coins to reduce their overall count, following a set of rules: Count the number of coins with each denomination, and write the denominations on a paper. Remove all denominations from the paper that have less than two coins. If there is at least one value written on the paper, find the smallest denomination in the paper let it be x. Find the two leftmost coins with denomination x, and let their positions be i and j. Pick up the two coins and remove them for one coin with a denomination of y = 2 * x and put that coin at position j (the position of the second coin picked). The user wants to know the final value of all the denominations in the line. Input Format The first line contains an integer n, the size of the array coins. Each of the next n lines contains an integer coins[i]. Output Format Return lon