Path Sum in Binary Tree
00:00
AmazonMicrosoft
Determine if a binary tree has a root-to-leaf path such that adding up all values along the path equals target sum.
Examples
Input → root=[5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum=22
Output → True
Note: 5→4→11→2
Input → root=[1,2,3], targetSum=5
Output → False
Input → root=[], targetSum=0
Output → False