Dynamic Programming in Go #3: Minimum Cost Path

  1. Storage and Meaning
  2. Direction
  3. Travel and Solve
  • Each cell represent cost to travel from that cell to last cell.
  • Direction: we will start from last cell -> last column (right to left) -> second last column and so on.
  • Every time we reach a cell, we will find cost from that cell by looking in all possible 4 directions.
  • The last cell already has ‘2’ because minimum cost to travel from last cell to the last cell is the value of the last cell itself.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hitesh Pattanayak

Hitesh Pattanayak

Senior Consultant @ Thoughtworks | 6.5 years of experience | Polyglot | Backend Developer | Kubernetes and AWS practitioner | Finance Enthusiast