Find Leaves of Binary Tree

Medium · Trees · about 20 minutes

Asked at LinkedIn, Google, Amazon, Meta.

Given the root of a binary tree, repeatedly collect all its leaves (left to right) and remove them, until the tree is empty. Return the collected groups in order.

Related guides