Problem · Tree
Find Leaves of Binary Tree
Learn this problemProblem statement
Repeatedly remove every current leaf from a binary tree. Return one row per removal round; values within a row follow their left-to-right postorder discovery order.
Function
findLeaves(root: TreeNode) → int[][]Examples
Example 1
root = [1,2,3,4,5]return = [[4,5,3],[2],[1]]The first round removes 4,5,3, then 2, then the root.
Constraints
- The tree contains between
1and10000nodes. -10^9 <= Node.val <= 10^9
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024