Algorithm · Karat · Medium
You are given a rectangular grid in which every cell is either open or blocked. A snake can travel only through open cells. The problem is posed in three successive parts. Part 1: Determine which rows and which columns the snake can traverse from one side of the grid to the opposite side in a single straight line, meaning every cell along that row or column is open. Part 2: The snake begins at a specified open cell on the boundary of the grid. Find the closest exit, where an…