Grokking Tree Coding Patterns for Interviews
Ask Author
Back to course home

0% completed

Bottom View Of the Binary Tree (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given the root of a binary tree, return an array that contains the nodes visible when looking at the tree from the bottom.

The bottom view is formed by collecting the nodes that would be visible if you were to stand directly beneath the tree and look up. If multiple nodes are aligned vertically, only the node at the deepest level should be included in the view.

Examples

Example 1

  • Input: root = [1, 2, 3]
  • Expected Output: [2, 1, 3]
  • Justification: From the bottom view, nodes 2, 1, and 3 are visible because they appear at the lowest vertic

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible