Swift | BFS
Complexity\n- Time complexity:\nO(n) \n\n- Space complexity:\nO(2^d) where d is the depth of the tree. The space complexity is driven by the maximum number of n
# Complexity\n- Time complexity:\n$$O(n)$$ \n\n- Space complexity:\n$$O(2^d)$$ where d is the depth of the tree. The space complexity is driven by the maximum number of nodes at any level in the tree.\n\n# Code\n```\nclass Solution {\n    func findBottomLeftValue(_ root: TreeNode?) -> Int {\n        var levelStack = [root!]\n        var result = 0\n        while !levelStack.isEmpty {\n            result = levelStack[0].val\n            levelStack = levelStack.flatMap{ [$0.left, $0.right].compactMap{ $0 } }\n        }\n        return result\n    }\n}\n```
['Swift']