Back to problems

Squirrel Simulation

Algorithm · Amazon · Medium

A squirrel lives on a rectangular grid with height rows and width columns. You are told where a tree stands (tree), where the squirrel begins (squirrel), and where every nut lies (nuts). Every location is written as [row, column], with rows and columns counted from zero. In a single move the squirrel steps to an adjacent cell above, below, to the left or to the right, and it may never step outside the grid. It can hold no more than one nut at once, so after picking up a nut…

Loading the rest of the question…