The Manhattan Tourist Problem Revisited

Let’s find a solution to the Manhattan Tourist Problem using dynamic programming.

Length of the longest path in a rectangular grid

You should now be ready to implement an algorithm solving the Manhattan Tourist Problem. The following pseudocode computes the length of the longest path to node (i, j) in a rectangular grid and is based on the observation that the only way to reach node (i, j) in the Manhattan Tourist Problem is either by moving south (↓) from (i − 1, j) or east (→) from (i, j − 1).

Get hands-on with 1200+ tech skills courses.