A path in a binary tree is a sequence of nodes connected by edges, with no node repeated. Given the root of a binary tree, return the maximum path sum of any non-empty path (it need not pass through the root).
Input: root = [1,2,3]
Output: 6
Topics: trees
Asked by: Amazon, Meta, Microsoft, Google, Bloomberg
Time complexity: O(n). Space complexity: O(h).