Algorithm · Square · Medium
You are given a dimension and a binary string (a string made up only of the characters 0 and 1). Use them to construct a two-dimensional grid whose cells hold the values 0 and 1. Next, starting from a given cell whose value is 1, move through the grid stepping only onto cells that contain 1, and look for a way out of the grid (an exit). The task proceeds in stages: Build the 2D matrix from the dimension and the binary string. From the starting cell, traverse only cells…