Suggestions to solve this problem?

Revision en1, by mohitn, 2020-09-28 18:19:27

You are given a grid of size (m, n) where each (i, j) is the cost of unlocking the door (i, j). You are given a starting position (sx, sy). And you have to collect 2 gems at position (g1x, g1y) and (g2x, g2y).

You only need to unlock a door once, no matter how many times you visit it. Find the minimum cost of collecting both the gems; you can move left, right, down, and up.

I was thinking of Dijkstra but how to manage the state?

Tags #graph, #shortest_path, #grid

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English mohitn 2020-09-28 18:19:27 473 Initial revision (published)