You are given the root of a binary tree and an integer targetSum. Your task is to find all root-to-leaf paths where the sum of the node values along the path equals targetSum.
A valid path must:
Return a list containing all such paths.
Input: root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22
Output: [[5,4,11,2],[5,8,4,5]]
Explanation: Two root-to-leaf paths sum to 22: 5 → 4 → 11 → 2 and 5 → 8 → 4 → 5.
Input: root = [1,2,3], targetSum = 5
Output: []
Explanation: No root-to-leaf path has a sum equal to 5.
Input: root = [], targetSum = 0
Output: []
Explanation: An empty tree has no paths.
Sign in to write, run, and submit your solution against the full test suite.