Path Sum in a Binary Tree

Given the root of a binary tree and an integer targetSum, return whether the tree has a root-to-leaf path such that the sum of all node values on that path equals targetSum.

A leaf is a node with...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: