Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of node values equals targetSum.
root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22[[5,4,11,2],[5,8,4,5]]root = [1,2,3], targetSum = 5[]path.add(node.val); rem -= node.valrem == 0 → add copy of path to resultpath.remove(last) — restore stateUnlike Path Sum I (stop at first match), we must find all paths. Backtracking lets us reuse a single path list: add a node on entry, explore both subtrees, then remove on exit. This gives O(h) space for the path instead of O(n) per path.