CPP | EASY | 1 LINE | 100 % BEATS | RECURSION
\n// In pair, returning take this value and not taking connected values or not taking this value and taking connected values.\nint rob(TreeNode* root) {\n\tretu
```\n// In pair, returning take this value and not taking connected values or not taking this value and taking connected values.\nint rob(TreeNode* root) {\n\treturn robMax(root).first;\n}\n\npair<int, int> robMax(TreeNode* root){\n\tif(!root) return {0, 0};\n\n\tpair<int, int> right = robMax(root->right);\n\tpair<int, int> left = robMax(root->left);\n\n\treturn {max(root->val + right.second + left.second, right.first + left.first), right.first + left.first};\n}\n```
['Recursion', 'C++']