Answer: Pinterest OA Question 2024 July | Trees | on-campus
Answer · Posted Jun 2026
Solution: Path Sum — Recursive DFS with Remaining Target Approach We use Recursive DFS and track the remaining sum needed as we go deeper. At each node, we subtract the node's value from the target. Base case (null node): Return false. Base case (leaf node): Return true if remaining - node.val == 0 — we found a valid path. Recursive case: Check left and right subtrees with the updated remaining value (remaining - node.val). If either subtree returns true, the ...
The full answer & interview discussion are available to premium members.
Log in Create a free account