Delivery Drone Route Minimizing the Steepest Single Climb

Last updated: November 29, 2026

Quick Overview

A drone flies over a grid of terrain heights from the top-left to the bottom-right cell, moving in four directions. A route's effort is the largest absolute height change between consecutive cells; return the minimum possible effort.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


A drone flies over a grid of terrain heights from the top-left to the bottom-right cell, moving in four directions. A route's effort is the largest absolute height change between consecutive cells; return the minimum possible effort.

Prime Air flight planning cares about the hardest climb on a route, not the total distance. The interviewer wants you to notice the bottleneck objective and adapt Dijkstra (or binary search with BFS, or union-find) to a minimax path.

What the Interviewer Expects
  • Identify the cost as a path maximum, not a sum
  • Adapt Dijkstra: candidate cost is max(current, edge)
  • Explain why the greedy pop order remains valid
  • Mention binary search plus BFS and union-find alternatives
  • Handle a 1 x 1 grid
Key Topics to Cover
Dijkstra
minimax path
grid graphs
binary search on answer
union-find
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Compare the complexity of the three approaches.
  • What if the drone may also move diagonally?
  • How would you answer many start and end queries on the same terrain?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: an m x n matrix of non-negative heights. Moves go up, down, left or right. Output: the smallest value E such that some route from (0,0) to (m-1,n-1) never steps across a height difference large...

High-Level Design

Treat each cell as a node and each adjacent pair as an edge with weight equal to the height difference. The cost of a path is the maximum edge weight, which is monotone non-decreasing as the path exte...


Submit Your Answer
Markdown supported