HashMap<Long ,long> EASY CODE
\n Add your space complexity here, e.g. O(n) \n\n# Code\n\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeN
\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n    int result=0;\n    public int pathSum(TreeNode root, int targetSum) {\n        if(root == null)return 0;\n        HashMap<Long,Integer>map=new HashMap<>();\n\n        map.put(0l,1);\n        long sum=0;\n        find_Sum(root,sum,targetSum,map);\n        return result;\n    }\n    public void find_Sum(TreeNode curr,long sum,int target, HashMap<Long,Integer>map){\n        if(curr==null)return ;\n        sum+=curr.val;\n\n        if(map.containsKey(sum-target))\n        result+=map.get(sum-target);\n\n        map.put(sum,map.getOrDefault(sum,0)+1);\n        find_Sum(curr.left,sum,target,map);\n        find_Sum(curr.right,sum,target,map);\n        map.put(sum,map.get(sum)-1);\n        return ;\n\n    }\n}\n```
['Java']