← Questions

Grid path that keeps its highest cell as low as possible

0
GoogleCodingLast asked Feb 2026

Each cell of an m x n grid holds a height. Find a path from the top-left to the bottom-right cell, moving up, down, left or right, whose highest cell is as low as possible, and return that height (the smallest threshold that still allows a path).

Solve it with Dijkstra on the maximum, or with binary search on the threshold plus BFS. Follow-ups: could DFS work, and what are the time complexities?

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding