Earliest Time a Moving Agent Enters the Ego Safety Radius

Last updated: November 29, 2026

Quick Overview

The ego vehicle and each nearby agent move with constant velocity in 2D. For each agent, compute the earliest time within a planning horizon at which its distance to the ego drops to a given safety radius, and return conflicting agents sorted by that time.

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

0

0

0 solved


The ego vehicle and each nearby agent move with constant velocity in 2D. For each agent, compute the earliest time within a planning horizon at which its distance to the ego drops to a given safety radius, and return conflicting agents sorted by that time.

Collision checking is the inner loop of motion planning, and a robotaxi built on the Nuro Driver evaluates many candidate trajectories against many agents every cycle. The interviewer wants a closed-form solution in relative coordinates, a correct reading of the quadratic's roots, and awareness of numeric edge cases.

What the Interviewer Expects
  • Move to relative position and velocity to reduce to one moving point
  • Set up the quadratic |p + v t|^2 = r^2 and interpret its roots
  • Handle already-in-conflict, zero relative velocity, and moving-apart cases
  • Clip results to the horizon
  • Discuss why real planners use swept shapes and sampled trajectories
Key Topics to Cover
computational geometry
quadratic equations
collision checking
motion 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 handle agents modeled as oriented rectangles instead of circles?
  • How do you extend this to piecewise-linear predicted trajectories?
  • How would you prune thousands of agents before doing exact checks?
  • How would prediction uncertainty change the safety radius?
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

Positions and velocities are 2D tuples, the radius already includes both footprints, and the horizon is in seconds. If the agent is already inside the radius the answer is 0. If it never comes within ...

High-Level Design

Let d = p1 - p2 and w = v1 - v2. The separation at time t is d + w t, so we solve ∣d+wt∣2=r2|d + w t|^2 = r^2, which is at2+bt+c=0a t^2 + b t + c = 0 with a=w⋅wa = w \cdot w, b=2d⋅wb = 2 d \cdot w, $c = d \cdot d - r^...


Submit Your Answer
Markdown supported

Related Questions