Out of Boundary Paths Problem
Out of Boundary Paths Problem — ExecCode Medium DSA Practice
Solve the Out of Boundary Paths problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
There is an m × n grid and a ball at (startRow, startCol). In one move the ball goes up, down, left, or right. You may make at most maxMove moves. Return how many paths take the ball out of the grid. Answer modulo 10⁹+7.
Examples
Input m = 2, n = 2, maxMove = 2, startRow = 0, startCol = 0; Output 6. Input m = 1, n = 3, maxMove = 3, startRow = 0, startCol = 1; Output 12
Constraints
1 ≤ m, n ≤ 50 0 ≤ maxMove ≤ 50
Practice Out of Boundary Paths free on ExecCode. Browse DSA problems, topic map, and placement guides.