In the coin collecting problem, a person is given a M x N matrix containing coins. The objective is to collect as many coins as possible and go to the end of the grid. To move from one cell to the next, they must traverse the grid on two diagonals. One traversal starts in the top left corner of the grid and the other starts at the bottom right corner. As they move, they must collect all the coins in the row below. However, they must not step out of the rectangle during the traversal.
A recursive method solves the problem efficiently. This approach entails calculating the same subproblem several times. A dynamic programming approach is another efficient way to solve the coin collection problem. In this approach, the solution of each subproblem is stored in a 2D array called dynamicprogTable. The dynamicprogTable has a size equal to the number of coins +1)*(Sum+1). The first column value of the dynamicprogTable is a one or a zero, while the last column value is another one or zero.