Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions solution/0400-0499/0404.Sum of Left Leaves/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
```

<!-- tabs:end -->

<!-- end -->