Find the minimum amount to purchase all types of stones.
The input is N*N matrix. We can consider it as N different arrays. We just need to add the minimum of every array. This is our required answer. We can do it by inputting one array at a time and finding the minimum of the array and then input the next array.
Author’s Solution can be found here.