Simple Java Recursion+Memoization solution
Time O(n) | Space O(n)\n   DP on trees\n \twe can choose b/w grandchildren+parent or children\n\n\n HashMap<TreeNode, Integer> map=new HashMap<>();\n    public 
*  Time O(n) | Space O(n)\n*   DP on trees\n* \twe can choose b/w grandchildren+parent or children\n```\n\n HashMap<TreeNode, Integer> map=new HashMap<>();\n    public int rob(TreeNode root) {\n        //we can choose b/w grandchildren+parent or children\n        if(root==null)return 0;\n        \n        if(map.containsKey(root)) return map.get(root);\n        \n        int total=0;\n        \n        if(root.left!=null)\n        total+=rob(root.left.left)+rob(root.left.right);\n        \n         if(root.right!=null)\n        total+=rob(root.right.left)+rob(root.right.right);\n        \n        int profit= Math.max((root.val +total), rob(root.left) + rob(root.right));\n        \n        map.put(root, profit);\n        return profit;\n    }\n```
['Dynamic Programming', 'Memoization', 'Java']