beast 98% EASY SOLUTION
Intuition:\nThe problem requires finding the leftmost value in the last row of a binary tree. To achieve this, a level-order traversal (BFS) can be employed. In
**Intuition:**\nThe problem requires finding the leftmost value in the last row of a binary tree. To achieve this, a level-order traversal (BFS) can be employed. In each level, the leftmost node can be identified and stored, eventually providing the leftmost node in the last level.\n\n**Approach:**\n1. Perform a level-order traversal using a queue.\n2. In each level, update the `last` pointer with the leftmost node.\n3. Return the value of the leftmost node after the traversal.\n\n**Complexity:**\n- Time complexity: $$O(n)$$, where \\(n\\) is the number of nodes in the binary tree. Each node is visited once during the level-order traversal.\n- Space complexity: $$O(m)$$, where \\(m\\) is the maximum number of nodes at a single level in the binary tree. In the worst case, the queue might store all nodes at the last level.\n\n# Code\n```\nclass Solution {\npublic:\n    int findBottomLeftValue(TreeNode* root) {\n        TreeNode* last=nullptr;\n        queue<TreeNode*>q;\n        if (root)\n            q.push(root);\n        while (!q.empty()) {\n            int size=q.size();\n            for (int i=0; i<size;i++) {\n                TreeNode* node=q.front();\n                q.pop();\n                if (i==0) \n                    last=node;\n                if (node->left)\n                    q.push(node->left);\n                if (node->right)\n                    q.push(node->right);\n            }\n        }\n        return last->val;\n    }\n};\n```
['Tree', 'Breadth-First Search', 'Binary Search Tree', 'Recursion', 'Queue', 'Binary Tree', 'C++']