标签:sum span node open hide imu == 判断 pen
要求
实现
1 class Solution { 2 public: 3 bool hasPathSum(TreeNode* root, int sum) { 4 5 if( root == NULL ) 6 return false; 7 8 if( root->left == NULL && root->right == NULL ) 9 return root->val == sum; 10 11 if( hasPathSum( root->left , sum - root->val ) ) 12 return true; 13 14 if( hasPathSum( root->right , sum - root->val ) ) 15 return true; 16 17 return false; 18 } 19 };
相关
标签:sum span node open hide imu == 判断 pen
原文地址:https://www.cnblogs.com/cxc1357/p/12678512.html