A board-game app shows a grid of rows × cols cells. A token starts in the top-left cell and must reach the bottom-right cell, moving only one cell right or one cell down at a time.
Write gridRoutes(rows, cols) that returns how many different routes there are, modulo 1000000007.
Input: rows = 2, cols = 2 Output: 2
Right then down, or down then right.
Input: rows = 3, cols = 3 Output: 6
Every route makes 2 down-moves and 2 right-moves. Choosing which 2 of the 4 moves go down gives C(4, 2) = 6.
1 <= rows, cols <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #649 Count Grid Routes. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.