2912. Number of Ways to Reach Destination in the Grid
You are given two integers
n
andm
which represent the size of a 1-indexed grid. You are also given an integerk
, a 1-indexed integer arraysource
and a 1-indexed integer arraydest
, wheresource
anddest
are in the form[x, y]
representing a cell on the given grid.You can move through the grid in the following way:
- You can go from cell
[x1, y1]
to cell[x2, y2]
if eitherx1 == x2
ory1 == y2
.- Note that you can’t move to the cell you are already in e.g.
x1 == x2
andy1 == y2
.Return the number of ways you can reach
dest
fromsource
by moving through the grid exactlyk
times.Since the answer may be very large, return it modulo
109 + 7
.
1 | class Solution { |