c++ || Recursive  + Memoization
C++\nWhen I started out doing Programming I used to find this question the most difficult. But Today I did It Without any Difficuty. Practice + Consistency  + H
**C++**\nWhen I started out doing Programming I used to find this question the most difficult. But Today I did It Without any Difficuty. Practice + Consistency  + Hard Work Can Change Everything. Good Luck.\n\n**Recursive Solution** ---->> This Gives TLE;\n```\nclass Solution {\npublic:\n    int rob(TreeNode* root) {\n        if(!root) return 0;\n        int self = root->val;\n        if(root->left) self += (rob(root->left->left) + rob(root->left->right));\n        if(root->right) self += (rob(root->right->left) + rob(root->right->right));\n        int nself = (rob(root->left) + rob(root->right));\n        return max(self ,nself);    \n    }\n};\n````\n**After Memoization** \n```\nclass Solution {\npublic:\n    unordered_map<TreeNode*,int> m;\n    int rob(TreeNode* root) {\n        if(m.count(root)) return m[root];\n        if(!root) return 0;\n        int self = root->val;\n        if(root->left) self += (rob(root->left->left) + rob(root->left->right));\n        if(root->right) self += (rob(root->right->left) + rob(root->right->right));\n        int nself = (rob(root->left) + rob(root->right));\n        m[root] = max(self ,nself);\n        return m[root];\n    }\n};\n```\n**IF YOU FIND THIS HELPFUL DO UPVOTE!!**
['Dynamic Programming', 'Tree', 'Recursion', 'C']