Find Bottom Left Tree Value (Leetcode 513)
Problem Link: https://leetcode.com/problems/find-bottom-left-tree-value/
class Solution:
def findBottomLeftValue(self, root: Optional[TreeNode]) -> int:
q=[root]
while(len(q)>0):
temp=[]
for i in range(len(q)):
node=q.pop()
if(node.left is not None):
q.insert(0,node.left)
if(node.right is not None):
q.insert(0,node.right)
temp.append(node)
return temp[0].val
PreviousLowest Common Ancestor of a Binary Search Tree(BST) (Leetcode 235)NextInsert into a Binary Search Tree (Leetcode 701)
Last updated