public boolean dfs(TreeNode root, int sum, int target) {
        if (root == null)
            return sum == target;
        if (root.left == null && root.right == null)
            return sum + root.val == target;
        if (root.left == null)
            return dfs(root.right, sum + root.val, target);
        if (root.right == null)
            return dfs(root.left, sum + root.val, target);
        return dfs(root.left, sum + root.val, target)
                || dfs(root.right, sum + root.val, target);
    }