12ms C++ dfs solution
//max_include_root = root->val + max_donot_include_root_left + max_donnot_include_root_right\n    //max_donot_include_root = max(max_include_root_left, max_donn
    //max_include_root = root->val + max_donot_include_root_left + max_donnot_include_root_right\n    //max_donot_include_root = max(max_include_root_left, max_donnot_include_root_left) + max(max_include_root_right, max_donnot_include_root_right)\n    \n    class Solution {\n    public:\n        int rob(TreeNode* root) {\n            int max_include_root = 0;\n            int max_donnot_include_root = 0;\n            return dfs(root, max_include_root, max_donnot_include_root);\n        }\n        \n        int dfs(TreeNode* root, int& max_include_root, int& max_donnot_include_root) {\n            if (root == NULL) {\n                max_include_root = 0;\n                max_donnot_include_root = 0;\n                return 0;\n            }\n            int max_donnot_include_root_left = 0;\n            int max_donnot_include_root_right = 0;\n\n            int max_include_root_left = 0;\n            int max_include_root_right = 0;\n\n            int max_left = dfs(root->left, max_include_root_left, max_donnot_include_root_left);\n            int max_right = dfs(root->right, max_include_root_right, max_donnot_include_root_right);\n\n            max_include_root = root->val + max_donnot_include_root_left + max_donnot_include_root_right;\n            max_donnot_include_root = max_left + max_right;\n\n            return max(max_include_root, max_donnot_include_root);\n        }\n    };
['Depth-First Search', 'C++']