# Find Bottom Left Tree Value LeetCode Solution

Here, We see Find Bottom Left Tree Value LeetCode Solution. This Leetcode problem is done in many programming languages like C++, Java, JavaScript, Python, etc. with different approaches.

# List of all LeetCode Solution

## Problem Statement

Given the root of a binary tree, return the leftmost value in the last row of the tree.

Example 1:

Input: root = [2,1,3]
Output: 1

Example 2:

Input: root = [1,2,3,4,null,5,6,null,null,7]
Output: 7

## Find Bottom Left Tree Value Leetcode Solution C++

``````class Solution {
public:
int findBottomLeftValue(TreeNode* root) {
queue<TreeNode*> q;
q.push(root);
int leftmost_value;
while (!q.empty()) {
TreeNode* node = q.front();
q.pop();
leftmost_value = node->val;
if (node->right) {
q.push(node->right);
}
if (node->left) {
q.push(node->left);
}
}
return leftmost_value;
}
};```Code language: PHP (php)```

## Find Bottom Left Tree Value Solution Java

``````class Solution {
public int findBottomLeftValue(TreeNode root) {
q.offer(root);
while(q.peek() != null) {
root = q.poll();
if(root.right !=null) q.offer(root.right);
if(root.left !=null) q.offer(root.left);
}
return root.val;
}
}```Code language: PHP (php)```

## Find Bottom Left Tree Value Solution JavaScript

``````var findBottomLeftValue = function(root) {
const queue = [root];
let leftmostValue;
while (queue.length > 0) {
const node = queue.shift();
leftmostValue = node.val;
if (node.right) {
queue.push(node.right);
}
if (node.left) {
queue.push(node.left);
}
}
return leftmostValue;
};```Code language: JavaScript (javascript)```

## Find Bottom Left Tree Value Solution Python

``````class Solution(object):
def findBottomLeftValue(self, root):
queue = deque([root])
leftmost_value = None
while queue:
node = queue.popleft()
leftmost_value = node.val
if node.right:
queue.append(node.right)
if node.left:
queue.append(node.left)
return leftmost_value``````
Scroll to Top