← Questions
Shortest path through a required cell when revisits are free
0
I was asked this
No reports yet. Sign in to say where you were asked it.
You get an N x M grid. Some cells are walls; the open cells include one start, one end and one checkpoint. You move up, down, left or right between open cells and may pass through a cell as often as you like, but a move only costs 1 when it enters a cell you have never visited before; going back over visited cells is free.
Find the cheapest walk from the start to the end that passes through the checkpoint on the way, or report that none exists. The interviewer wrapped it in a story; this is what it reduces to.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
