Algorithm · Apple · Medium
A ball is placed on an m x n board, initially at [startRow, startColumn]. For every step, it may travel to a neighboring cell by going up, down, left, or right. Determine how many possible paths cause the ball to leave the board using no more than maxMove steps. Since this count may grow large, report it modulo 10^9 + 7. Examples Example 1: Input: m = 2, n = 2, maxMove = 1, startRow = 0, startColumn = 0 Output: 2 Explanation: From the upper-left cell, moving upward or…
Checking your access…