You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(!root->left && !root->right) // checks if the sum at the root is equal to target sum
return sum-root->val == 0;
return hasPathSum(root->left,sum-root->val) || hasPathSum(root->right,sum-root->val); // Traverses the tree to find the solution at one of the leaf nodes