Find Bottom Left Tree Value

Medium

Description

Given the root of a binary tree, return the leftmost value in the last (deepest) row of the tree. The leftmost value is the first node at the deepest level from left to right.

Examples

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

Bottom left is 1.

Input:root = [5]
Output:5
Explanation:

Single node tree - the root is both the bottom row and leftmost node.

Input:root = [10,8,12,3,9,null,15,null,6]
Output:6
Explanation:

The last row contains nodes [6]. Node 6 is the leftmost (and only) node in the bottom row.

Constraints

  • 1 ≤ nodes ≤ 10⁴

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!