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..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 @@ -213,6 +213,25 @@ 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; + } +}; +``` +