✅Simple approach ,fast and explained (WITH PICTURES)
Simple Approach:-\nAs theif cannot enter two directly connected house, so he cannot enter root and its children. So, he has only two options :\n1. Either he ent
***Simple Approach:-***\nAs theif cannot enter two directly connected house, so he cannot enter root and its children. So, he has only two options :\n1. Either he enter the **root and its grandchildren**.\n2. Or he enter the **children only**.\n\nLets write the recursive solution.\n\nWe will use pair (**pair<int,int> t**) to store answer :\n1. **root value**+**sum of grandchildren** in **t.first** and\n2. **sum of children** in **t.second**\n![image](https://assets.leetcode.com/users/images/a50cae51-7559-4181-8256-e48012c14957_1638731240.4278634.jpeg)\n\n\n```\nclass Solution {\npublic:\n    \n    pair<int,int> solve(TreeNode* root){\n        if(root == NULL)\n            return {0,0};\n   \n        pair<int,int> l = solve(root->left);\n        pair<int,int> r = solve(root->right);\n        \n        pair<int,int> t;\n        \n        //here l.second + r.second = Sum of grandchildren and l.first + r.first = Sum of children\n        //t.first contains maxmium money theif can rob till this house(node)\n        t.first = max(root->val + l.second + r.second, l.first + r.first);\n        \n        //t.second contains the sum of children\n        t.second = l.first + r.first;\n        \n        return t;\n    }\n    \n    int rob(TreeNode* root) {\n        return solve(root).first;\n    }\n};\n```\n Thanks for reading : )
['Depth-First Search']