Class Solution
java.lang.Object
g0501_0600.s0576_out_of_boundary_paths.Solution
576 - Out of Boundary Paths.<p>Medium</p>
<p>There is an <code>m x n</code> grid with a ball. The ball is initially at the position <code>[startRow, startColumn]</code>. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply <strong>at most</strong> <code>maxMove</code> moves to the ball.</p>
<p>Given the five integers <code>m</code>, <code>n</code>, <code>maxMove</code>, <code>startRow</code>, <code>startColumn</code>, return the number of paths to move the ball out of the grid boundary. Since the answer can be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/04/28/out_of_boundary_paths_1.png" alt="" /></p>
<p><strong>Input:</strong> m = 2, n = 2, maxMove = 2, startRow = 0, startColumn = 0</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/04/28/out_of_boundary_paths_2.png" alt="" /></p>
<p><strong>Input:</strong> m = 1, n = 3, maxMove = 3, startRow = 0, startColumn = 1</p>
<p><strong>Output:</strong> 12</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= m, n <= 50</code></li>
<li><code>0 <= maxMove <= 50</code></li>
<li><code>0 <= startRow < m</code></li>
<li><code>0 <= startColumn < n</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
findPaths
(int m, int n, int maxMoves, int startRow, int startCol)
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findPaths
public int findPaths(int m, int n, int maxMoves, int startRow, int startCol)
-