0366. Find Leaves of Binary Tree

https://leetcode.com/problems/find-leaves-of-binary-tree

Description

Given the root of a binary tree, collect a tree's nodes as if you were doing this:

  • Collect all the leaf nodes.

  • Remove all the leaf nodes.

  • Repeat until the tree is empty.

Example 1:

Example 2:

Constraints:

  • The number of nodes in the tree is in the range [1, 100].

  • -100 <= Node.val <= 100

ac

Last updated

Was this helpful?