dsa · easy

Path Sum

GreyOrangeTreeRecursionFoundation

Return whether the tree has a root-to-leaf path summing to target.

Arguments

**Example**

`` Input: [1,[2,None,None],[3,None,None]] 4 Output: True ``

Constraints

Number of nodes in [0, 500] Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[1,[2,None,None],[3,None,None]]
4

Expected:
true

Example 2

Input:
[1,[2,None,None],[3,None,None]]
5

Expected:
false

Open in the Dojo editor