Round 1
Questions: Given the root of a binary tree, collect and remove all of its leaves in a top-down manner, and repeat the process until the tree becomes empty. You should return a list of lists where:
- The first list contains all leaves removed in the first round.
- The second list contains all leaves removed in the second round.
- And so on, until the tree is empty.
Example 1
Input:
1 / \ 2 3 / \ \ 4 5 6
Output:
[[4,5,6],[2,3],[1]]
Explanation:
- First round: Remove leaves [4,5,6], remaining tree:
1 / \ 2 3
- Second round: Remove leaves [2,3], remaining tree:
1
- Third round: Remove root [1], tree is now empty.
Example 2
Input:
1 / 2 / 3
Output:
[[3],[2],[1]]
Constraints
- The number of nodes in the tree is in the range [1, 100].
- -100 <= Node.val <= 100
Follow-up
Can you solve this problem in O(n) time complexity?
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.