I am attempting to find the minimum cost path of an array. The code works when restricted to moving either down or to the right, but not diagonally.
Issue:
return min(findMinCost( cost, m - 1, n),
findMinCost(cost, m, n - 1),
findMinCost(cost, m - 1, n - 1)) + cost[m - 1][n - 1];
I added the third argument for a diagonal movement, however it seems I cannot compare 3 arguments using min. What would be the easiest way to make this comparison? Thank you!