Advanture to Count Max Moves
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.
numRows = 8 numColumns = 8 curRow = 5 curColumn = 3 laserCoordinates = [[1, 6], [2, 8]] return = 3
🌷- Fastest SF CommutePHONE SCREEN · Seen May 2026
- Find First Anagram IndexPHONE SCREEN · Seen Apr 2026
- Minimize CommuteOA · Seen Apr 2026
- Difference Between Sums of PositionsSeen Sep 2024
- Longest Common Prefix of Number PairsSeen Sep 2024
- Subarray CountingSeen Sep 2024
- Write 'L' on MatrixSeen Sep 2024
- Binary String RequestsSeen Aug 2024
public int solution(int numRows, int numColumns, int curRow, int curColumn, int[][] laserCoordinates) {
// write your code here
}