After the rain, Chris can finally walk back to his hostel. In order to do so, he must go through a park which can be seen as a matrix of size \(N\times M\). The entrance is on the bottom left and the exit is on the top right corner of the park. Chris wants to take the shortest path, so he will only move upward or to the right.
Unfortunately, the snails decided to come out for some fresh air! Each unit square has some number of snails on it. What is the minimum number of snails Chris will need to pass through?
Details and Assumptions:
1 2 3 4
Chris walks to the squares that has \(1\rightarrow 3 \rightarrow 1 \rightarrow 2 \rightarrow 2\) number of snails respectively.
Inspired by the number of snails I saw on my way back.