#3651

Minimum Cost Path with Teleportations

candidate master · 1550 · lc hard +32 · 45.7% accepted · 418 likes · top 29%

Description

A m x n grid and integer k are given. Starting at (0, 0), reach (m-1, n-1) with minimum cost. Normal moves go right or down; cost is the destination cell value. Teleportation (at most k times) jumps from (i, j) to any (x, y) with grid[x][y] <= grid[i][j] at zero cost. Return the minimum total cost.

Code

1
2
3