Back to problems

Find best downhill ski run from a start

Algorithm · Airbnb · Medium

A 2D integer matrix grid stores elevations on a mountain. A downhill route begins at a specified cell (sr, sc). At each step, the skier may move to one of the four orthogonal neighboring cells, but only if the neighbor's elevation is strictly smaller than the current cell's elevation. The route stops when no neighbor has a smaller elevation. The score of a route is the greatest number of distinct cells that can be visited in any valid downhill route beginning at the start…

Checking your access…