Maximum Sum BST in Binary Tree
HardLeetCodeAdvanced Trees (BST, LCA, Tree DP)
Approach hintTry it first, then revealHide
Return a tuple from each subtree in post-order: whether it is a BST, its minimum, its maximum and its sum. A node roots a BST when both children do and its value lies strictly between the left maximum and the right minimum.