Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Minimum Cost Path with Teleportations

XPChallenge Points: 30
levelLevel: Hard

You are given a m x n integer grid grid and an integer k.
You start from the top-left cell (0, 0) and must reach the bottom-right cell (m - 1, n - 1).
There are two types of moves allowed:
1. Normal Move:
o You can move right or down from your current position (i, j)
o The cost is the value of the destination cell
2. Teleport Jump:
o You can teleport from any cell (i, j) to any other cell (x, y) if grid[x][y] <= grid[i][j].
o The cost of teleportation is 0.
o You can teleport at most k times.
Your task is to find the minimum total cost to reach the cell (m - 1, n - 1) starting from (0, 0).

Example 1:

Input: grid = [[2, 4, 3], [5, 6, 2], [7, 3, 1]] k = 1

Output: 6

Example 2:

Input: grid = [[1, 5], [2, 1], [3, 2]] k = 2

Output: 0

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result