intmaxGain(TreeNode* root){ if(!root) return0; int l = maxGain(root -> left); int r = maxGain(root -> right); res = max({res, l + r + root -> val, r + root -> val, l + root -> val, root -> val}); returnmax({root -> val, root -> val + l, root -> val + r}); } };