Dev
Mentor
Coach Interview AI
Mock Interview AI
Coding Problems
Blog
Pricing
Toggle theme
Sign In
Get Started
Toggle theme
Loading...
For the best coding experience, use a desktop browser.
Easy
Tree
Path Sum
Return true if tree has root-to-leaf path with sum equal to
targetSum
.
Examples
Input:
root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22
Output:
true
Sample Test Cases
Case 1 Input:
[5,4,8,11,null,13,4,7,2,null,null,null,1] 22
Expected:
true
Reset
Run
Submit
Loading editor...
Test Case
Output
Submission
Case 1 Input:
[5,4,8,11,null,13,4,7,2,null,null,null,1] 22
Expected:
true