Recursive Logic Python3 5 Lines of Code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def rob(self, root: Optional[TreeNode]) -> int:\n        def dfs(root):\n            if not root: return [0,0]\n            leftpair,rightpair=dfs(root.left),dfs(root.right)\n            withroot,without=root.val+leftpair[1]+rightpair[1],max(leftpair)+max(rightpair)\n            return [withroot,without]\n        return max(dfs(root))\n    #please upvote me it would encourage me alot\n\n        \n```
['Python3']