Find the earliest day a snowy mountain range becomes passable, minimizing climbs.
Each element of the altitude array is the initial altitude at that position, e.g. altitude = [1, 2, 3, 2, 0], starting at index 0. Each row of the days matrix is one day and each column the snowfall at that index: snowfall greater than 0 raises the altitude at that index by that amount, and two consecutive days with 0 snowfall at an index melt the altitude there by 1 unit. Example: days[0] = [1, 0, 1, 2, 1] gives new altitudes [2, 2, 4, 4, 1]; days[1] = [1, 0, 1, 1, 0] then melts index 1 (two consecutive zeros), giving [3, 1, 5, 5, 1]. Movement from one index to the next is only possible with an altitude difference of at most 1 unit. Find the earliest day on which the mountain range becomes passable. If there are multiple ways to pass, find the path that requires the minimum number of climbs.
Community answers
Related courses


