You are given two integers m and n, representing the dimensions of an m $ imes$ n grid, and a waitCost of size m $ imes$ n.
You start at cell (0, 0) at second (m - 1, n - 1).
At each second
If
You may move to an adjacent cell, either right to (r, c + 1) or down to (r + 1, c). The direction of each move must alternate from the previous move, though the very first move can be in either direction. Entering cell (r, c) incurs a cost of
Alternatively, you may choose to wait at your current cell (r, c) and pay a cost of waitCost[r][c].
If
You cannot move and must wait at your current cell (r, c), paying a cost of waitCost[r][c].
Return the minimum total cost required to reach cell (m - 1, n - 1).
Constraints:
m, n
m $ imes$ n
waitCost.length m
waitCost[0].length n
waitCost[i][j]
You are given two integers m and n, representing the dimensions of an m $ imes$ n grid, and a waitCost of size m $ imes$ n.
You start at cell (0, 0) at second (m - 1, n - 1).
At each second
If
You may move to an adjacent cell, either right to (r, c + 1) or down to (r + 1, c). The direction of each move must alternate from the previous move, though the very first move can be in either direction. Entering cell (r, c) incurs a cost of
Alternatively, you may choose to wait at your current cell (r, c) and pay a cost of waitCost[r][c].
If
You cannot move and must wait at your current cell (r, c), paying a cost of waitCost[r][c].
Return the minimum total cost required to reach cell (m - 1, n - 1).
Constraints:
m, n
m $ imes$ n
waitCost.length m
waitCost[0].length n
waitCost[i][j]