Earliest Time to Collision With Constant Velocity Agents

Last updated: November 29, 2026

Quick Overview

Given the ego vehicle and a list of tracked agents as circles with positions and constant velocities, return the agent with the earliest contact time within a planning horizon, or none.

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

0

0

0 solved


Given the ego vehicle and a list of tracked agents as circles with positions and constant velocities, return the agent with the earliest contact time within a planning horizon, or none.

Time to collision is a basic building block in safety checks, similar in spirit to what an independent collision avoidance layer evaluates many times per second. The interviewer checks the geometry (relative motion and a quadratic), numerical care, and how the candidate reasons about the limits of constant velocity assumptions.

What the Interviewer Expects
  • Reduces the problem to relative position and relative velocity
  • Solves the quadratic for when distance equals the sum of radii and takes the smaller root
  • Handles already-overlapping agents, zero relative velocity and separating agents
  • Filters to the horizon and keeps the minimum
  • Discusses why constant velocity is a coarse approximation
Key Topics to Cover
relative motion
quadratic equations
collision checking
safety metrics
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 handle agents represented as oriented boxes instead of circles?
  • How would you include uncertainty in agent velocity?
  • What changes if ego follows a curved planned trajectory?
  • How would you make this fast for hundreds of agents at 10 Hz?
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

Ego and each agent: (x, y, vx, vy, r). Contact happens when center distance equals r_ego + r_agent. Return (id, t) with the smallest t in [0, horizon], or None. Already overlapping means `...

High-Level Design

Work in the ego frame: p = p_agent - p_ego, w = v_agent - v_ego. Distance squared at time t is |p + w t|^2. Setting it equal to R^2 gives a t^2 + b t + c = 0 with a = w.w, b = 2 p.w, `c ...


Submit Your Answer
Markdown supported

Related Questions