Plan a Grid Path Around Obstacles Inflated by Robot Radius

Last updated: November 29, 2026

Quick Overview

Given an occupancy grid with obstacle cells and a robot radius in cells, mark every cell within that BFS distance of an obstacle as unsafe, then return the shortest 4-connected path length from start to goal through safe cells, or -1.

Applied Intuition
Coding & Algorithms
Software Engineer
Applied Intuition
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given an occupancy grid with obstacle cells and a robot radius in cells, mark every cell within that BFS distance of an obstacle as unsafe, then return the shortest 4-connected path length from start to goal through safe cells, or -1.

Occupancy grids appear across Applied Intuition's off-road, mining and defense autonomy work. The interviewer checks multi-source BFS for obstacle inflation and a second BFS for planning, keeping both linear in grid size.

What the Interviewer Expects
  • Inflate obstacles with a multi-source BFS from all obstacle cells at once
  • Stop expanding inflation at the radius
  • Reject start or goal cells that are unsafe
  • Run a standard BFS for the shortest path
  • Explain why per-obstacle BFS would be too slow
Key Topics to Cover
multi-source BFS
grids
distance transform
path planning
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
  • How would you use Euclidean rather than Manhattan inflation?
  • How would you prefer paths that keep more clearance, not just avoid collisions?
  • How would you update inflation incrementally when one cell changes?
  • How do you handle a robot that is not circular?
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 is a list of strings with # for obstacles. Radius r counts 4-neighbor steps: a cell at BFS distance at most r from any obstacle is unsafe; r = 0 marks only obstacles. Start and goal are `(row...

High-Level Design

Seed one BFS queue with every obstacle at distance 0 and expand up to distance r. Cells still at -1 afterward are safe. That is a discrete distance transform in one pass. Then a regular BFS from start...


Submit Your Answer
Markdown supported