Diameter of a Binary Tree
Easy · Trees · about 15 minutes
Asked at Meta, Google, Amazon.
Over all pairs of nodes in a binary tree, take the path connecting them and count its edges. Return the largest count. The longest path might not go through the root.