Given the root of a binary tree, return the maximum sum of any path. A path may start and end at any nodes, must follow parent-child edges, and cannot revisit a node.
Constraints
1 <= number of nodes <= 3 * 10^4
-1000 <= node value <= 1000
The input is a valid binary tree
Interviewer
Your question is Maximum Path Sum in Tree. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.