Intuition
Not much to this problem. We just convert the tree to a graph, find the start node and then perform a BFS.
Note: there is also a very tricky DFS solution that is similar to Diameter of a binary tree…look over it.
Implementation
Visual
Review 1
BFS is trivial, I still don’t fully understand the DFS solution but essentially you need to count depths differently depending on where the start was found…in other-words its very annoying. Stick to BFS for this problem type.