FastPrepFind Bottom Left Tree Value

Find Bottom Left Tree Value

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW
Learn

Problem statement

Given a nonempty binary tree, return the value of its leftmost node on the deepest level.

Function

findBottomLeftValue(root: TreeNode) → int

Examples

Example 1

root = [2,1,3]return = 1

The deepest level contains 1 and 3; 1 is leftmost.

Example 2

root = [1,2,3,4,null,5,6,null,null,7]return = 7

Seven is the only node on the deepest level.

Constraints

  • The tree has between 1 and 10^5 nodes.
  • Node values are 32-bit signed integers.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int findBottomLeftValue(TreeNode root) {
  // Write your code here.
}
root[2,1,3]
expected1
Checking account…