← Questions

Longest safe straight move for a robot between lasers

0
DatabricksCodingLast asked Aug 2024

A board has some lasers, each at a cell; a laser destroys every cell in its row and its column. A robot stands on a given cell, which is safe even if a beam crosses it. It picks one of the four directions and moves straight until the board edge or until the next cell is destroyed. Return the most cells it can move in the best direction. Store the laser rows and columns in sets and walk each direction.

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