Path Sum

Easy
Trees Tree DFS

Given a binary tree and target sum, return true if root-to-leaf path sum equals target.

Constraints

Nodes ≤ 5000

Examples

Example 1:
Input: 5 4 8 11 null 13 4 7 2 null null null 1 22
Output: true
Example 2:
Input: 1 2 3 5
Output: false
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.