✅Accepted| | ✅Easy solution || ✅Short & Simple || ✅Best Method
\n# Code\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(
\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    pair<int, int> solve(TreeNode* t)\n    {\n        if(t==NULL)\n        return {0,0};\n        auto p1=solve(t->left);\n        auto p2=solve(t->right);\n        pair<int, int> p;\n        p.first=t->val+p1.second+p2.second;\n        p.second=max(p1.first, p1.second)+max(p2.first, p2.second);\n        return p;\n    }\n    int rob(TreeNode* root) {\n       auto p= solve(root);\n       return max(p.first, p.second);\n    }\n};\n```\nPlease **UPVOTE** if it helps \u2764\uFE0F\uD83D\uDE0A\nThank You and Happy To Help You!!
['C++']