Hacker News new | ask | show | jobs
by DeathArrow 1461 days ago
And since a tree is a graph, you can just use adjacency matrix and two loops. :)

O(n^2) but very simple.