Threat Weighted Grid Route Planning Around No Fly Zones

Last updated: November 29, 2026

Quick Overview

Given an occupancy grid where some cells are no-fly zones and every cell has a non-negative threat cost, find the cheapest 4-connected route from start to goal where entering a cell costs 1 plus its threat value, and return the cost and path.

Shield AI
Coding & Algorithms
Software Engineer
Shield AI
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given an occupancy grid where some cells are no-fly zones and every cell has a non-negative threat cost, find the cheapest 4-connected route from start to goal where entering a cell costs 1 plus its threat value, and return the cost and path.

Mission planning in Hivemind has to trade distance against exposure to radar or air defense, which maps cleanly onto shortest path with weighted cells. The onsite interviewer checks that you pick Dijkstra over BFS for weighted costs, reconstruct the path, and reason about how the planner scales and replans.

What the Interviewer Expects
  • Recognizes BFS is wrong once costs are non-uniform
  • Implements Dijkstra with lazy deletion of stale heap entries
  • Reconstructs the path from parent pointers
  • Handles blocked start, blocked goal and unreachable goal
  • Discusses A* with an admissible heuristic as an improvement
Key Topics to Cover
Dijkstra
Priority queue
Path reconstruction
Cost maps
Replanning
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
  • What heuristic keeps A* admissible here, and why is Manhattan distance valid?
  • Threat values change mid-flight as new intel arrives. How do you replan cheaply?
  • How would you add a turn penalty so the route is flyable for a fixed-wing aircraft?
  • The grid is 10,000 by 10,000. What do you change?
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

Grid R x C, grid[r][c] == 1 is no-fly, threat[r][c] >= 0. Moving into a cell costs 1 + threat. Return (cost, path) or (None, []) when unreachable. I would confirm the start cell's own cost...

High-Level Design

Because all edge weights are non-negative, Dijkstra gives the optimum. Each cell is a node with up to four outgoing edges. Use a min-heap of (cost, cell), a distance map and a parent map. Stop as so...


Submit Your Answer
Markdown supported

Related Questions