Find the sum along root-to-leaf paths of a tree
You are treating res and curList as if they are Globals, and, since they are globals, there is no reason to return ret in the function at all.

As a result of this, your code is not re-entrant (you can only have one method calling your pathSum at any one point in time).

The right solution to this is to pass the curList and ret values as parameters to the method, convert it to private, and create a new public method which creates the instances as you need them.....

public ArrayList&lt;ArrayList&lt;Integer&gt;&gt; pathSum(TreeNode root, int sum) {
    ArrayList&lt;ArrayList&lt;Integer&gt;&gt; res = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();
    ArrayList&lt;Integer&gt; curList = new ArrayList&lt;Integer&gt;();
    pathSum(root, sum, curList, res);
    return res;
}


private void pathSum(TreeNode root, int sum, 
            ArrayList&lt;Integer&gt; curList, ArrayList&lt;ArrayList&lt;Integer&gt;&gt; res) {
    ....
    ** change the methods called as part of the recursion too**
    ....
}


That is the big structural change, but I would recommend more:


methods should not return specific List implementation types unless those types have special features you need. your method should return List&lt;List&lt;Integer&gt;&gt; and not ArrayList&lt;ArrayList&lt;Integer&gt;&gt;
convert curList to an array of int[], and the return valye of the system to List
you do the calculation sum-root.val in multiple places. Firstly, it should be spaced properly: sum - root.val, and secondly, you should save it as a variable once, and re-use that variable in the places where it currently is a function


About the complexity

you ask if worst case is \$O(n^2)\$ ... no, it is not.

Worst case is \$O(n \log(n))\$. This is my reasoning:


the depth of a binary tree is about \$\log(n)\$.
The deepest a binary tree can be is depth n, but, in that case there is only one possible solution, so the complexity will be two \$O(n)\$ operations, one to scan the single deep branch, and another to copy the array.
the worst case is actually a fully-balanced tree where every leaf node matches the intended sum, in which case the number of solutions is proportional to \$O(n)\$, but the actual copy to the array will be of \$O(log(n))\$ elements


So, My assessment is \$O(n \log(n))\$

Feel free to debate this... I am not 100% certain....