Microsoft Interview Question

Diameter of binary tree.

Interview Answer

Anonymous

Apr 15, 2020

First did the same thing as for graphs - found the furthest node, and then furthest from it. Later realized I can do better without additional memory, which is just traverse the tree once and keep updating the answer looking at chikdren of every node.