PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Minimize maximum height along a grid path

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic pathfinding and graph-modeling skills, specifically reasoning about grid-based route selection where the objective is defined by an aggregate maximum over visited cell heights.

  • hard
  • Google
  • Coding & Algorithms
  • Software Engineer

Minimize maximum height along a grid path

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given an `m x n` grid `heights` of **distinct** integers representing terrain heights. You start at the top-left cell `(0,0)` and want to reach the bottom-right cell `(m-1,n-1)` by moving **4-directionally** (up, down, left, right) within the grid. Define the **cost** of a path as the **maximum height value** among all cells on that path. ### Task Return the **minimum possible path cost**, i.e., among all valid paths from `(0,0)` to `(m-1,n-1)`, minimize the maximum height encountered. ### Input - `heights`: `m x n` integer grid ### Output - An integer: the minimum achievable value of `max(height on path)` ### Notes / Follow-ups discussed - A typical approach is to model this as a shortest-path variant (e.g., Dijkstra where path “distance” is `minimize max-so-far`). - Follow-up: Can this be implemented with DFS? If yes, what approach would you use (plain DFS vs DFS + binary search vs memoization), and what is the time complexity?

Quick Answer: This question evaluates algorithmic pathfinding and graph-modeling skills, specifically reasoning about grid-based route selection where the objective is defined by an aggregate maximum over visited cell heights.

Related Interview Questions

  • Solve Rooms and Top-K Streams - Google (medium)
  • Find Containing Range - Google (medium)
  • Rearrange Tasks With Cooldown - Google (medium)
  • Implement Employee Management and Expression Evaluation - Google (medium)
  • Solve Three Array and Matrix Path Problems - Google (medium)
Google logo
Google
Jan 4, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0
Loading...

You are given an m x n grid heights of distinct integers representing terrain heights. You start at the top-left cell (0,0) and want to reach the bottom-right cell (m-1,n-1) by moving 4-directionally (up, down, left, right) within the grid.

Define the cost of a path as the maximum height value among all cells on that path.

Task

Return the minimum possible path cost, i.e., among all valid paths from (0,0) to (m-1,n-1), minimize the maximum height encountered.

Input

  • heights : m x n integer grid

Output

  • An integer: the minimum achievable value of max(height on path)

Notes / Follow-ups discussed

  • A typical approach is to model this as a shortest-path variant (e.g., Dijkstra where path “distance” is minimize max-so-far ).
  • Follow-up: Can this be implemented with DFS? If yes, what approach would you use (plain DFS vs DFS + binary search vs memoization), and what is the time complexity?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.