JAVA Solution || Easy to understand || Intuitive
\nclass Solution {\n    public int pathSum(TreeNode root, int targetSum) {\n        if(root==null){\n            return 0;\n        }\n        ArrayList<Integer
```\nclass Solution {\n    public int pathSum(TreeNode root, int targetSum) {\n        if(root==null){\n            return 0;\n        }\n        ArrayList<Integer> path=new ArrayList<>();\n        int[]count=new int[1];\n        helper(root,targetSum,count,path);\n        return count[0];\n    }\n    public void helper(TreeNode root,int targetSum,int[] count,ArrayList<Integer> path){\n        if(root==null){\n            return;\n        }\n        path.add(root.val);\n        int sum=0;\n        for(int i=path.size()-1;i>=0;i--){\n            sum+=path.get(i);\n            if(sum==targetSum){\n                count[0]++;\n            }\n        }\n        helper(root.left,targetSum,count,path);\n        helper(root.right,targetSum,count,path);\n        path.remove(path.size()-1);\n    }\n}\n```
['Recursion', 'Java']