You are given logs, where logs[i] = [timestamp, riderA, riderB] indicates that riderA and riderB shared a ride at timestamp. The logs are sorted in strictly increasing timestamp order.
Two riders are connected if they shared a ride directly or can be linked transitively through other riders. Return the earliest timestamp when every rider that appears anywhere in logs belongs to a single connected component. If this never happens, return "-1".
In this practice version, timestamps are represented as strings so the input can stay in a simple string[][] format. Because the logs are already sorted, you only need to return the first timestamp that completes the full connection.
Follow-up note: If the stream can also contain block events such as ["1670000541", "Bob", "Dan", "blocked"], edges can disappear over time. Plain Union-Find no longer works online because deletions break monotonicity. Typical solutions use offline processing with rollback Union-Find or another dynamic-connectivity technique.
At timestamp 5, the edge between Bob and Alice merges the two remaining groups into one connected component.
Even after the final log, {Alice, Boo, Evel} and {Bob, Charlie, Dan} remain disconnected.
Reported as a LeetCode-style union-find graph question for software engineer phone screen and onsite rounds.