You are given a mountain range represented by an array of length ****, where each element represents the initial altitude at that position.
- Initial Altitudes:
altitude = [1, 2, 3, 2, 0] - Starting Position: You begin at index 0.
You are given a days matrix, where each row represents a single day and each column corresponds to the amount of snowfall at that specific length (index).
- Snowfall: If the value for a day is greater than 0, the altitude at that index increases by that amount.
- Melting: If there are two consecutive days with 0 snowfall at a specific index, the snow begins to melt, and the altitude at that position decreases by 1 unit.
Example Calculation:
-
Day 1:
days[0] = [1, 0, 1, 2, 1] -
New Altitudes:
[2, 2, 4, 4, 1](Initial + Day 1 snow) -
Day 2:
days[1] = [1, 0, 1, 1, 0] -
At index 1, there have been 2 consecutive days of
0snowfall. Therefore, it melts by 1. -
New Altitudes:
[3, 1, 5, 5, 1]
A person can only move from index to index if the altitude difference is manageable:
- This means you can only climb up 1 unit or climb down 1 unit at a time.
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.


