Cheapest Route on an Occupancy Grid for a Bidirectional Vehicle

Last updated: November 29, 2026

Quick Overview

On a grid with blocked cells, a vehicle aligned on a horizontal or vertical axis can move one cell either way along its axis at cost 1 or switch axis in place at a fixed cost; find the minimum cost from start to goal.

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

0

0

0 solved


On a grid with blocked cells, a vehicle aligned on a horizontal or vertical axis can move one cell either way along its axis at cost 1 or switch axis in place at a fixed cost; find the minimum cost from start to goal.

The Zoox robotaxi is symmetric and drives equally well in both directions, so there is no penalty for reversing, unlike a conventional car. This onsite coding question checks whether a candidate can model state beyond position, choose Dijkstra over plain BFS when edge costs differ, and reason about planning on occupancy grids.

What the Interviewer Expects
  • Models state as (row, col, axis) rather than position only
  • Recognizes unequal costs and uses Dijkstra (or 0-1 BFS style buckets when costs are small)
  • Skips stale heap entries correctly
  • Returns early when goal is popped and -1 when unreachable
  • Analyzes O(V log V) with V = 2 * R * C
Key Topics to Cover
Dijkstra
state-space search
occupancy grids
bidirectional vehicle kinematics
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 the state space change for a conventional car with a reverse penalty and four headings?
  • How would you add an A* heuristic that stays admissible with turn costs?
  • What if cells carry a soft cost from an occupancy probability?
  • How does this relate to lattice planners used on real vehicles?
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 of strings, # blocked. The vehicle starts on axis 0 (horizontal). Moves: one cell left or right on axis 0, up or down on axis 1, cost 1 each. Switching axis in place costs turn_cost. Goal is ...

High-Level Design

Position alone is not enough because the same cell on a different axis has different future options. State is (r, c, axis), giving 2 * R * C nodes with at most three edges each. Since a turn costs m...


Submit Your Answer
Markdown supported

Related Questions