432. Find the Weak Connected Component in the Directed Graph
Find the number Weak Connected Component in the directed graph. Each node in the graph contains a label and a list of its neighbors. (a connected set of a directed graph is a subgraph in which any two vertices are connected by direct edge path.)
Notice
Sort the element in the set in increasing order
Example
Given graph:123456A----->B  C \     |  |   \    |  |   \   |  |    \  v  v     ->D  E <- F
Return {A,B,D}, {C,E,F}. Since there are two connected component which are {A,B,D} and {C,E,F}
Union Find
又是一道Union Find的题目,当然这种题目DFS和BFS也都可以做
| 
 | 
 |