Graph Theory37 sections · 1633 units
Open in Course

LeetCode 543 Diameter of Binary Tree - Problem Statement

Find the diameter of a binary tree

Given a binary tree, find the diameter: the longest path between any two nodes. The path does not have to pass through the root.

This problem is a direct application of Tree DP. You compute height for each subtree and track the longest path that bends through each node. You will solve this problem fully in the Tree Diameter & Center section, where you will compare the DP approach with a Double BFS approach.