Easy 4 lines C++ DFS
4 lines brute force, 1656ms.\n\n    int rob(TreeNode* root) {\n        return DFS(root, true);\n    }\n    \n    int DFS(TreeNode* root, bool canRob){\n        
4 lines brute force, 1656ms.\n```\n    int rob(TreeNode* root) {\n        return DFS(root, true);\n    }\n    \n    int DFS(TreeNode* root, bool canRob){\n        if(!root) return 0;\n        int noRob = DFS(root->left, true) + DFS(root->right, true);\n        return canRob ? max(root->val + DFS(root->left, false) + DFS(root->right, false), noRob) : noRob;\n    }\n```\nHere is a greedy one, 22ms.\n**idea:**\nEach node only has 2 status, be robbed or not.\nStore amount of money under 2 status into a vector<int>v(2).\nv[0]: it's not robbed.\nv[1]: it's robbed.\n```\n    int rob(TreeNode* root) {\n        auto res = DFS(root);\n        return max(res[0], res[1]);\n    }\n    \n    vector<int> DFS(TreeNode* root){\n        if(!root) return {0,0};\n        auto left = DFS(root->left);\n        auto right = DFS(root->right);\n        vector<int>res(2);\n        res[0] = max(left[0], left[1]) + max(right[0], right[1]);\n        res[1] = root->val + left[0] + right[0];\n        return res;\n    }\n```
['Depth-First Search', 'C++']