File tree Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -716,9 +716,55 @@ public void Traversal(TreeNode root, int depth)
716
716
return ;
717
717
}
718
718
```
719
+ ``` csharp
720
+ /*
721
+ * @lc app=leetcode id=513 lang=csharp
722
+ * 迭代法
723
+ * [513] Find Bottom Left Tree Value
724
+ */
725
+
726
+ // @lc code=start
727
+ public class Solution
728
+ {
729
+ public int FindBottomLeftValue (TreeNode root )
730
+ {
731
+ Queue < TreeNode > que = new Queue <TreeNode >();
732
+
733
+ if (root != null )
734
+ {
735
+ que .Enqueue (root );
736
+ }
737
+
738
+ int ans = 0 ;
739
+ while (que .Count != 0 )
740
+ {
741
+
742
+ int size = que .Count ;
743
+ for (var i = 0 ; i < size ; i ++ )
744
+ {
745
+ var curNode = que .Peek ();
746
+ que .Dequeue ();
747
+ if (i == 0 ){
748
+ ans = curNode .val ;
749
+ }
750
+ if (curNode .left != null )
751
+ {
752
+ que .Enqueue (curNode .left );
753
+ }
754
+ if (curNode .right != null )
755
+ {
756
+ que .Enqueue (curNode .right );
757
+ }
758
+ }
759
+
760
+ }
761
+ return ans ;
762
+ }
763
+ }
764
+ // @lc code=end
765
+ ```
719
766
720
767
<p align =" center " >
721
768
<a href =" https://programmercarl.com/other/kstar.html " target =" _blank " >
722
769
<img src =" ../pics/网站星球宣传海报.jpg " width =" 1000 " />
723
770
</a >
724
-
You can’t perform that action at this time.
0 commit comments