Path Sum
1 bool hasPathSum(TreeNode *root, int sum) { 2 // Start typing your C/C++ solution below 3 // DO NOT write int main() function 4 if(root == NULL) 5 return false; 6 if(sum == root->val && root->left==NULL && root->right==NULL) 7 return true; 8 return hasPathSum(root->left, sum-root->val)||hasPathSum(root->right, sum-root->val); 9 }