Simple readable python solution


  • 0
    C
    class Solution(object):
    def findBottomLeftValue(self, root):
        if root:
            return self.findBottomLeftValueHelper(root)
        else:
            return None
    
    def findBottomLeftValueHelper(self, root):
        level = []
        next_level = [root]
        while True:
            level = next_level
            next_level = []
            for node in level:
                if node.left:
                    next_level.append(node.left)
                if node.right:
                    next_level.append(node.right)
            if len(next_level) == 0:
                return level[0].val

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.