From c201b947a5bb4510b5c0214ec652c6300a2c6760 Mon Sep 17 00:00:00 2001 From: El nino <69737612+el-nino2020@users.noreply.github.com> Date: Sat, 14 Jan 2023 15:06:56 +0800 Subject: [PATCH] =?UTF-8?q?Update=200112.=E8=B7=AF=E5=BE=84=E6=80=BB?= =?UTF-8?q?=E5=92=8C.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原有的代码leetcode上无法通过编译 --- problems/0112.路径总和.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/0112.路径总和.md b/problems/0112.路径总和.md index 7aa5f2a1..b1f01336 100644 --- a/problems/0112.路径总和.md +++ b/problems/0112.路径总和.md @@ -155,14 +155,14 @@ public: 以上代码精简之后如下: ```cpp -class solution { +class Solution { public: bool hasPathSum(TreeNode* root, int sum) { - if (root == null) return false; + if (!root) return false; if (!root->left && !root->right && sum == root->val) { return true; } - return haspathsum(root->left, sum - root->val) || haspathsum(root->right, sum - root->val); + return hasPathSum(root->left, sum - root->val) || hasPathSum(root->right, sum - root->val); } }; ```