Earliest Time When Everyone Became Friends

Given n people labeled from 0 to n - 1 and a list of friendship logs, where each log is [timestamp, x, y] meaning that x and y became friends at timestamp.

Friendship is transitive: if ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: