people attendees numbered from 0 to people - 1. The log meetings holds records [t, x, y]: at time t, attendees x and y got to know each other. The records are in no particular order, and the same pair may appear more than once.
Acquaintance is mutual. Two attendees are linked if they know each other directly or through a chain of mutual acquaintances.
Return the earliest time at which every attendee is linked to every other one. If that never happens, return -1.meetings=[[9, 1, 2], [3, 0, 1], [15, 2, 3], [12, 0, 2]], people=4 → 15
At time 3 people 0 and 1 are linked, at time 9 person 2 joins them, the meeting at 12 changes nothing, and at 15 person 3 is linked in: everyone is in one group.
meetings=[[1, 0, 1], [2, 2, 3]], people=4 → -1
Two separate groups remain, {0, 1} and {2, 3}, so the answer is -1.
meetings=[[50, 0, 2], [20, 1, 2], [70, 0, 1]], people=3 → 50
t are distinctmeetings=[[9, 1, 2], [3, 0, 1], [15, 2, 3], [12, 0, 2]], people=4
15
Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.