3 ms·And since a tree is a graph, you can just use adjacency matrix and two loops. :) O(n^2) but very simple.by DeathArrow 4y agoAnd since a tree is a graph, you can just use adjacency matrix and two loops. :) O(n^2) but very simple.