3603. Minimum Cost Path with Alternating Directions II
You are given two integers
mandnrepresenting the number of rows and columns of a grid, respectively.The cost to enter cell
(i, j)is defined as(i + 1) * (j + 1).You are also given a 2D integer array
waitCostwherewaitCost[i][j]defines the cost to wait on that cell.You start at cell
(0, 0)at second 1.At each step, you follow an alternating pattern:
- On odd-numbered seconds, you must move right or down to an adjacent cell, paying its entry cost.
- On even-numbered seconds, you must wait in place, paying
waitCost[i][j].Return the minimum total cost required to reach
(m - 1, n - 1).
1 | class Solution { |