Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Moves in a Grid

med
30 min
Try to solve the Maximum Number of Moves in a Grid problem.

Statement

You are given a 22D integer array grid of size m $ imes$ n.

You can begin at any cell in the first column (column 00) and perform moves according to the following rules. From a cell (row, col), you can move to any of the following cells provided that the target cell lies within the grid and contains a value strictly greater than the value of grid[row][col]:

  • (row - 11, col + 11)

  • (row, col + 11)

  • (row + 11, col + 11)

Return the maximum number of moves that can be performed.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 2≤2 \leq m, n ≤1000\leq 1000

  • 4≤4 \leq m * n ≤105\leq 10^5

  • 1≤1 \leq grid[i][j] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Moves in a Grid

med
30 min
Try to solve the Maximum Number of Moves in a Grid problem.

Statement

You are given a 22D integer array grid of size m $ imes$ n.

You can begin at any cell in the first column (column 00) and perform moves according to the following rules. From a cell (row, col), you can move to any of the following cells provided that the target cell lies within the grid and contains a value strictly greater than the value of grid[row][col]:

  • (row - 11, col + 11)

  • (row, col + 11)

  • (row + 11, col + 11)

Return the maximum number of moves that can be performed.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 2≤2 \leq m, n ≤1000\leq 1000

  • 4≤4 \leq m * n ≤105\leq 10^5

  • 1≤1 \leq grid[i][j] ≤106\leq 10^6