#3742
Maximum Path Score in a Grid
expert · 1055 · lc medium +32 · 36.6% accepted · 105 likes · top 14%
Description
Given an m x n grid where each cell holds 0, 1, or 2 (cell value v > 0 adds v to score and 1 to cost) and an integer k, find the maximum score of any top-left to bottom-right path (moving only right or down) whose total cost does not exceed k, or return -1 if no valid path exists.
Code
1
2
3