private void pathSumUtil(Node root, int sum, List<List<Integer>> result, List<Integer> currentPath) {
        if (root == null) {
            return;
        }
        if (root.left == null && root.right == null) {
            if (root.data == sum) {
                currentPath.add(root.data);
                result.add(new ArrayList<>(currentPath));
                currentPath.remove(currentPath.size() - 1);
            }
            return;
        }
        currentPath.add(root.data);
        pathSumUtil(root.left, sum - root.data, result, currentPath);
        pathSumUtil(root.right, sum - root.data, result, currentPath);
        currentPath.remove(currentPath.size() - 1);
    }
Date 10/06/2016
@author Tushar Roy

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.

Time complexity O(n)

https://leetcode.com/problems/path-sum/
https://leetcode.com/problems/path-sum-ii/
src/com/interview/tree/PathSum.java