aboutsummaryrefslogtreecommitdiff
path: root/find_bottom_left_tree.py
diff options
context:
space:
mode:
Diffstat (limited to 'find_bottom_left_tree.py')
-rw-r--r--find_bottom_left_tree.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/find_bottom_left_tree.py b/find_bottom_left_tree.py
new file mode 100644
index 0000000..d1a2444
--- /dev/null
+++ b/find_bottom_left_tree.py
@@ -0,0 +1,21 @@
+# 513. Find Bottom Left Tree Value
+
+"""
+given the 'root' of a binary tree, return the leftmost value in the last row
+of the tree
+"""
+
+
+class TreeNode(object):
+ def __init__(self, val=0, left=None, right=None):
+ self.val = val
+ self.left = left
+ self.right = right
+
+
+class Solution(object):
+ def findBottomLeftValue(self, root):
+ queue = [root]
+ for node in queue:
+ queue += filter(None, (node.right, node.left))
+ return node.val