Java programming

 This program is like a game, take the original array as stacks of coins, and I need to add more coins in order to make the height of stacks be decreasing in each row. And the Solve function needs to print out the modified array and return the minimum number of coins that I need to add to the stacks to make it decrease in rows and columns. It should also be able to handle dynamic array.