Search⌘ K
AI Features

Solution: Boundary of Binary Tree

Let's solve the Boundary of Binary Tree problem using the Tree Depth-First Search pattern.

Statement

Given the root of a binary tree, return the values of its boundary in order.

The boundary is formed by concatenating the following four parts:

11. The root node itself (the root is never considered a leaf in this problem).

...