Tap here to switch tabs
Problem
Submissions

Problem: Out of Boundary Paths

med
30 min
Try to solve the Out of Boundary Paths problem.

Statement

An m $ imes$ n grid contains a ball initially located at coordinate (startRow, startColumn). In each step, you can move the ball to one of the four adjacent cells: up, down, left, or right. A move can also take the ball past the edge of the grid.

Given the integers m, n, maxMove, startRow, and startColumn, return the number of distinct paths to move the ball off the boundary of the grid using at most maxMove moves. Since the answer can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq m, n ≤50\leq 50

  • 0≤0 \leq maxMove ≤50\leq 50

  • 0≤0 \leq startRow << m

  • 0≤0 \leq startColumn << n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Out of Boundary Paths

med
30 min
Try to solve the Out of Boundary Paths problem.

Statement

An m $ imes$ n grid contains a ball initially located at coordinate (startRow, startColumn). In each step, you can move the ball to one of the four adjacent cells: up, down, left, or right. A move can also take the ball past the edge of the grid.

Given the integers m, n, maxMove, startRow, and startColumn, return the number of distinct paths to move the ball off the boundary of the grid using at most maxMove moves. Since the answer can be very large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq m, n ≤50\leq 50

  • 0≤0 \leq maxMove ≤50\leq 50

  • 0≤0 \leq startRow << m

  • 0≤0 \leq startColumn << n