C++ | Space optimized approach
\nclass Solution {\npublic:\n    // Time complexity - O(N)\n    // vector<int> of size = 2 where -> [pick, not pick]\n    vector<int> traverser(TreeNode* curr){
```\nclass Solution {\npublic:\n    // Time complexity - O(N)\n    // vector<int> of size = 2 where -> [pick, not pick]\n    vector<int> traverser(TreeNode* curr){\n        if(!curr){\n            return {0, 0};\n        }\n        \n        vector<int>l, r, t;\n        l = traverser(curr->left);\n        r = traverser(curr->right);\n        \n        t.push_back( l[1] + r[1] + curr->val );\n        t.push_back( max(l[0], l[1]) + max(r[0], r[1]) );\n        \n        return t;\n    }\n    int rob(TreeNode* root) {\n        vector<int>holder = traverser(root);\n        return max(holder[0], holder[1]);\n    }\n};\n```
['Depth-First Search', 'C++']