Skip to content

Commit 5dd4175

Browse files
authored
Create 0513-find-bottom-left-tree-value.kt
1 parent 9289006 commit 5dd4175

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: kotlin/0513-find-bottom-left-tree-value.kt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
fun findBottomLeftValue(root: TreeNode?): Int {
3+
var cur = root
4+
with (LinkedList<TreeNode?>()) {
5+
addLast(root)
6+
while (isNotEmpty()) {
7+
cur = removeFirst()
8+
cur?.right?.let { addLast(it) }
9+
cur?.left?.let { addLast(it) }
10+
}
11+
}
12+
return cur?.`val` ?: 0
13+
}
14+
}

0 commit comments

Comments
 (0)