摘要:
这道题应该是how to bipartite a graph Taken from GeeksforGeeks Following is a simple algorithm to find out whether a given graph is Birpartite or not using B 阅读全文
摘要:
Recursion: 返回的时候返回lca和depth,每个node如果有大于一个子节点的depth相同就返回这个node,如果有一个子节点depth更深就返回个子节点lca,这个o(n)就可以了 Iteration: tree的recursion换成iteration处理,一般用stack都能解决 阅读全文