rows rows and cols columns of intersections. A courier stands at the top-left intersection and has to deliver an order to the bottom-right one.
To save time, the courier only ever moves down or right to a neighbouring intersection. Return the number of distinct routes from the start to the delivery point.
The answer is guaranteed not to exceed 2·10⁹.rows=2, cols=4 → 4
The courier makes 1 move down and 3 moves right; the down move can come first, second, third or fourth, so there are 4 routes.
rows=3, cols=3 → 6
Out of 4 moves, two go down and two go right: C(4, 2) = 6 ways to arrange them.
rows=1, cols=9 → 1
rows=2, cols=4
4
Run checks the first 3 tests in your browser. Submit checks all 27 tests on the server, hidden ones included.