A network dashboard shows a heatmap of latencies as a grid, where grid[r][c] is the delay in milliseconds of passing through cell (r, c). A request enters at the top-left cell and leaves at the bottom-right cell, and at each step it moves one cell right or one cell down.
Write cheapestRoute(grid) that returns the smallest total delay of such a route, counting the first and the last cell.
Input: grid = [[2,4,1],[1,6,1],[5,3,2]] Output: 10
Right, right, down, down: 2 + 4 + 1 + 1 + 2.
Input: grid = [[1,2,4],[3,5,6]] Output: 13
Right, right, down: 1 + 2 + 4 + 6.
1 <= rows, cols <= 2000 <= grid[r][c] <= 100Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #503 Cheapest Route Across a Latency Heatmap. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.