We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9923f8 commit 34de1fdCopy full SHA for 34de1fd
problems/0404.左叶子之和.md
@@ -651,6 +651,23 @@ impl Solution {
651
}
652
653
```
654
+### C#
655
+```C#
656
+// 递归
657
+public int SumOfLeftLeaves(TreeNode root)
658
+{
659
+ if (root == null) return 0;
660
+
661
+ int leftValue = SumOfLeftLeaves(root.left);
662
+ if (root.left != null && root.left.left == null && root.left.right == null)
663
+ {
664
+ leftValue += root.left.val;
665
+ }
666
+ int rightValue = SumOfLeftLeaves(root.right);
667
+ return leftValue + rightValue;
668
669
+}
670
+```
671
672
<p align="center">
673
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
0 commit comments