Skip to main content
All Questions

Find the earliest day a snowy mountain range becomes passable, minimizing climbs.

Unlock detailed company stats for this questionUpgrade

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

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.