Back to problems

Answer Repeated Shortest Increasing-Path Queries

Algorithm · Uber · Hard

You are given a rectangular integer grid and a list of target values. For each target, you must find a shortest strictly increasing path that starts at the top-left cell and ends at the cell containing the target value. Moving from one cell to a neighbor that shares a side is allowed only if the value in the neighbor is strictly larger than the value in the current cell. Path length is measured by the number of moves (edges). Reaching the starting cell itself requires zero…

Checking your access…