PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Uber

Find earliest time all riders become connected

Last updated: Mar 29, 2026

Quick Overview

Assesses understanding of graph connectivity, temporal event processing, and dynamic graph data-structures for determining when a set of nodes becomes a single connected component.

  • hard
  • Uber
  • Coding & Algorithms
  • Software Engineer

Find earliest time all riders become connected

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

You are given a time-ordered log of events involving Uber riders. Each event has a timestamp and two rider names. Event types: 1. `t X shared-ride-with Y` — riders `X` and `Y` shared a ride at time `t`, which creates an (undirected) connection between them. Two riders are considered **connected** if there is a path of shared rides between them (transitive connectivity). For example, if `A` shared with `B` and `B` shared with `C`, then `A` is connected to `C`. Example (already sorted by time): - `t1 Alice shared-ride-with Bob` - `t2 Charlie shared-ride-with Dan` - `t3 Bob shared-ride-with Charlie` - `t4 Alice shared-ride-with Eve` - `t5 Bob shared-ride-with Dan` Task: - Return the **earliest timestamp** at which **all riders that appear in the logs** become connected in a single connected component. If this never happens, return an appropriate value (e.g., `-1`). Follow-up: The log may also contain **block** events: - `t X blocked Y` — starting at time `t`, treat riders `X` and `Y` as **no longer directly connected by their shared-ride relationship** (i.e., the edge between `X` and `Y` is removed for times `>= t`, even if they shared earlier). How would you modify your approach to still find the earliest time when all riders are connected, given that connections can be both added (`shared-ride-with`) and removed (`blocked`)?

Quick Answer: Assesses understanding of graph connectivity, temporal event processing, and dynamic graph data-structures for determining when a set of nodes becomes a single connected component.

Related Interview Questions

  • Implement Minesweeper and Word Search - Uber (medium)
  • Implement Store Autocomplete - Uber (medium)
  • Implement Cache Eviction And Seat Assignment - Uber (medium)
  • Schedule Non-Overlapping Meetings Efficiently - Uber (hard)
  • Evaluate an Arithmetic Expression - Uber
Uber logo
Uber
Jan 3, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
9
0

You are given a time-ordered log of events involving Uber riders. Each event has a timestamp and two rider names.

Event types:

  1. t X shared-ride-with Y — riders X and Y shared a ride at time t , which creates an (undirected) connection between them.

Two riders are considered connected if there is a path of shared rides between them (transitive connectivity). For example, if A shared with B and B shared with C, then A is connected to C.

Example (already sorted by time):

  • t1 Alice shared-ride-with Bob
  • t2 Charlie shared-ride-with Dan
  • t3 Bob shared-ride-with Charlie
  • t4 Alice shared-ride-with Eve
  • t5 Bob shared-ride-with Dan

Task:

  • Return the earliest timestamp at which all riders that appear in the logs become connected in a single connected component. If this never happens, return an appropriate value (e.g., -1 ).

Follow-up: The log may also contain block events:

  • t X blocked Y — starting at time t , treat riders X and Y as no longer directly connected by their shared-ride relationship (i.e., the edge between X and Y is removed for times >= t , even if they shared earlier).

How would you modify your approach to still find the earliest time when all riders are connected, given that connections can be both added (shared-ride-with) and removed (blocked)?

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.