For graph as follow: The topological order can be: [0, 1, 2, 3, 4, 5][0, 2, 3, 1, 5, 4] 思路:标准topo排序的算法;算indegree,然后每次remove node,neighbor的入度全部减1,以此循环; /*** Definition for Directed graph.* class
====BFS 找联通量,找component. Number of Islands (BFS, DFS 都可以做) Surrounded Regions 算法是:先收集四个周边的 O,然后用BFS或者DFS向里面扩展,visited记录connect点,最后如果没有被visited到的O,会变成X;T: O(m*n), Space: O(m*n). Is Graph Bipartite (
K. Topological Sort time limit per test 8.0 s memory limit per test 256 MB input standard input output standard output Consider a directed graph G of N nodes and all edges (u→v) such th