Practice Out of Boundary Paths
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A ball starts at (startRow, startColumn) on an m by n grid. In one move it can go one cell up, down, left or right. Count the paths that move it outside the grid using at most maxMove moves, and return the count modulo 10^9 + 7.
Source: Out of Boundary Paths on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
m = 2, n = 2, maxMove = 2, startRow = 0, startColumn = 0
Output
6
# Example 2
Input
m = 1, n = 3, maxMove = 3, startRow = 0, startColumn = 1
Output
12
Constraints
1 <= m, n <= 50
0 <= maxMove <= 50
0 <= startRow < m
0 <= startColumn < n
Related LeetCode Problems
Practice more problems similar to Out of Boundary Paths.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.