InterviewDB
Question
·
Washington DC
Snowy Mountain: Find the Longest Downhill Path in a 2D Elevation Grid
Question Details
Problem You are given an m x n matrix where each cell represents the elevation at that point. A skier can move from a cell to an adjacent cell (up, down, left, right) only if the destination is strictly lower. Find the length of the longest such path. Example: Approach Use memoized DFS. For each cell, dfs(r, c) returns the longest path starting there. A cell's result depends only on strictly lower neighbors, so there are no cycles — memoization is safe. Follow-ups What is the time and space comp…
Full Details
🔒
Unlock all Karat questions
Full insider details, leaked discussions, and candidate experiences.
or every company, $100/year →About This Question
This is a reported interview question from a karat interview.
It covers the following topics: Matrix, Coding, Graph, Dynamic Programming .