Description
Solutions
Advanture to Count Max Moves
🤘 INTERN

tomtom's note: Feel free to check out source image for the original problem statement :)

Imagine a vast grid-like board, stretching across numRows by numColumns, where a little robot begins its journey. This robot, however, isn’t alone on the board—there are dangerous lasers positioned at specific coordinates, marked by the array laserCoordinates. Each laser is like a sentinel, protecting its row and column by destroying anything that dares to cross its path.

Our brave robot starts its adventure at a particular spot on the board, given by the coordinates (curRow, curColumn). It’s protected from the laser beams in its starting position, but the moment it moves, it’s in danger. The robot can only move in straight lines—either left, right, up, or down—but it must be cautious. The robot’s goal is to explore the board and count the maximum number of cells it can safely move through before any of the laser beams find and destroy it.

Example 1:

Input:  numRows = 8, numColumns = 8, curRow = 5, curColumn = 3, laserCoordinates = [[1, 6], [2, 8]]
Output: 3
Explanation:
Picture an 8x8 board where a courageous little robot is about to embark on a perilous journey. But danger lurks in the form of two powerful lasers, positioned at the coordinates (1, 6) and (2, 8). These lasers are like sentinels, guarding their rows and columns fiercely, ready to destroy anything that crosses their path.
Constraints:
    🌷
Thumbnail 0
Thumbnail 1
Testcase

Result
Case 1

input:

output: