Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    576 - Out of Boundary Paths\.

    Medium

    There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. 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 at most maxMove moves to the ball.

    Given the five integers m, n, maxMove, startRow, startColumn, return the number of paths to move the ball out of the grid boundary. Since the answer can be very large, return it modulo <code>10<sup>9</sup> + 7</code>.

    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 &lt;= m, n &lt;= 50

    • 0 &lt;= maxMove &lt;= 50

    • 0 &lt;= startRow &lt; m

    • 0 &lt;= startColumn &lt; n

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer findPaths(Integer m, Integer n, Integer maxMoves, Integer startRow, Integer startCol)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait