You are given a binary tree. Return the diameter: the length of the longest path between any two nodes. The path may or may not pass through the root. This is the LeetCode version.
Unlike the CSES problem which uses adjacency lists, here you have TreeNode pointers with left/right children. The DP approach fits naturally. For each node, combine left and right heights to check if a path through this node is the longest.