Earliest Moment Every Driver Joins One Radio Mesh

Last updated: November 29, 2026

Quick Overview

Driver devices form links over time, each log entry (timestamp, a, b) connecting two of n drivers; return the earliest timestamp after which all drivers are in one connected group, or -1 if that never happens.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Driver devices form links over time, each log entry (timestamp, a, b) connecting two of n drivers; return the earliest timestamp after which all drivers are in one connected group, or -1 if that never happens.

Offline-first features in Uber's driver app (for example, sharing incident alerts at events with poor coverage) could rely on device meshes. The phone screen checks that you sort by time, union as you go, and stop when the component count reaches one.

What the Interviewer Expects
  • Sort link events by timestamp
  • Track the number of components, decrementing on successful unions
  • Return the timestamp of the union that makes the count one
  • Return -1 if never connected
  • Handle n = 1
Key Topics to Cover
union find
component counting
sorting events
connectivity over time
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 if links also expire after some time?
  • Return the time at which the largest group first exceeds half of all drivers
  • How would you answer many 'are a and b connected at time t' queries?
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
  • Input: n drivers 0..n-1, logs list of (t, a, b) in any order.
  • Output: smallest t at which all drivers are connected; -1 if never; 0 conventionally for n = 1 (already connected), co...
High-Level Design

Sort logs by time. Start with n components. For each link, if union(a, b) merges two different components, decrement the count. The moment the count hits 1, that log's timestamp is the answer, sin...


Submit Your Answer
Markdown supported