🧠 Before you code — what pattern fits?
Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum. A path must go downwards (parent to child) but need not start at the root or end at a leaf.
([10,5,-3,3,2,null,11,3,-2,null,1], 8) → 3
🎬 Video explanation · Knowledge Center
Your solution runs against 2 unit tests, including edge and large-value cases.
Loading...
Test console · 2 unit tests
Submit your code to run it against all 2 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.