Reported August 2026
Googleunion find

Earliest Time of Full Connection

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

The mistake that sinks most first attempts at this Google OA question is processing events in the order they're given. The input is unsorted, so your answer comes out wrong on the very first example. Google reported this one in August 2026. It's "Earliest Time of Full Connection", and it's a sort plus union-find problem wearing a graph costume. You have n nodes, timed edges, and you want the first moment everything is one component. If you blank on the structure during the live OA, StealthCoder is the invisible safety net that reads the problem and hands you the solution. Know the trick first.

The problem

There are n nodes numbered from 0 to n - 1. Each row [time, u, v] in events records that an undirected connection between nodes u and v becomes available at time.
Connections never disappear. Determine the earliest timestamp at which every node belongs to one connected component. Events may be given in any order, and multiple events may share a timestamp.
Return that earliest timestamp, or -1 if the graph never becomes fully connected.

Function
earliestFullConnection(n: int, events: int[][]) → int

Examples
Example 1
n = 4
events = [[5,0,1],[2,2,3],[8,1,2]]
return = 8
At time 5, the components are {0,1} and {2,3}. The event at time 8 joins them, so 8 is the first fully connected time.
Example 2
n = 3
events = [[4,0,1],[2,1,2],[3,0,2]]
return = 3
After sorting by time, 1 and 2 connect at time 2. Node 0 joins that component at time 3.
Example 3
n = 4
events = [[1,0,1],[2,2,3]]
return = -1
The two connected pairs are never joined, so the graph does not become fully connected.

Constraints
2 <= n <= 100000
0 <= events.length <= 200000
Every event has the form [time, u, v].
0 <= time <= 1000000000
0 <= u, v < n and u != v.
Duplicate connections and equal timestamps are allowed.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Sort events by time ascending. Run union-find over n nodes and track the component count, starting at n. For each event, find the roots of u and v. If they differ, union them and decrement the count. When the count hits 1, return that event's time. If you finish the loop with more than one component, return -1. The pitfall is skipping the sort, or returning the wrong time when edges share a timestamp. Duplicates and redundant edges just fail the root check, so they cost nothing. Use path compression and union by size or rank so 200000 events stay near O(E log E) from the sort. Also handle events being empty: with n >= 2, that's always -1. StealthCoder is your hedge if the union-find code slips under pressure during the live OA, but this pattern is short enough to write cold.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Earliest Time of Full Connection cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as the earliest moment when everyone become friends. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Earliest Time of Full Connection FAQ

What's the trick in Earliest Time of Full Connection?+

Sort events by timestamp, then add edges one at a time with union-find. Count components starting at n. Each successful union drops the count by one. The moment it reaches 1, the current event's time is your answer. If it never does, return -1.

How hard is this problem really?+

Medium at most. If you know union-find, it's about 20 lines. The difficulty is noticing that unsorted input means you must sort first, and that a connectivity question over time maps to union-find instead of repeated BFS.

Why not run BFS or DFS after each event?+

With up to 200000 events and 100000 nodes, rerunning a traversal per event is far too slow. Union-find merges components incrementally in near-constant time per event, so total cost is dominated by the sort.

How do I handle equal timestamps and duplicate edges?+

You don't need special logic. Sorting groups equal times together, and a duplicate or redundant edge finds the same root for both nodes, so it's skipped. Return the time of the event that brings the count to 1.

How do I prepare for this in 48 hours?+

Write union-find from memory twice, with path compression and union by size. Then solve this problem once end to end, including the -1 case. Test the three given examples by hand. That covers the whole pattern for this Google question.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it