From 981b9c5ac4f8cd505166a139f7682ff06e0e7fbd Mon Sep 17 00:00:00 2001 From: Ali Nawaz <110383490+AliPythonDev@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:10:22 +0500 Subject: [PATCH 1/2] Update README_EN.md --- .../0404.Sum of Left Leaves/README_EN.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md b/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md index a402d69f5531d..bd7e2ae2fcc60 100644 --- a/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md +++ b/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md @@ -213,6 +213,24 @@ int sumOfLeftLeaves(struct TreeNode* root) { } ``` +```cpp +class Solution { + public: + int sumOfLeftLeaves(TreeNode* root) { + if (root == nullptr) + return 0; + int ans = 0; + if (root->left) { + if (root->left->left == nullptr && root->left->right == nullptr) + ans += root->left->val; + else + ans += sumOfLeftLeaves(root->left); + } + ans += sumOfLeftLeaves(root->right); + return ans; + } +}; +``` From ad756ca863183fadd1e233669a98943958fbafb1 Mon Sep 17 00:00:00 2001 From: AliPythonDev Date: Tue, 16 Apr 2024 07:21:36 +0000 Subject: [PATCH 2/2] style: format code and docs with prettier --- solution/0400-0499/0404.Sum of Left Leaves/README_EN.md | 1 + 1 file changed, 1 insertion(+) diff --git a/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md b/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md index bd7e2ae2fcc60..6c329c4405ef6 100644 --- a/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md +++ b/solution/0400-0499/0404.Sum of Left Leaves/README_EN.md @@ -231,6 +231,7 @@ class Solution { } }; ``` +