Shortest Path to Collect All Coins

Asked at WeRide · Coding Questions · Difficulty: Hard

On a grid there are up to 10 coins distributed in various cells. Each cell is either empty or contains a coin. Starting from a given starting cell, find the length of the **shortest path that collects all the coins**. You may move only horizontally or vertically (one step per move), and cells may be revisited. Optimize for time complexity.

Loading the problem…