List of Depths
Given a binary tree, design an algorithm which creates a list of all the nodes at each depth.
If you have a tree with depth D, you will have D lists.
Example:
4
/ \
2 6
/ \ / \
1 3 5 7
Output:
Depth 1: [4]
Depth 2: [2, 6]
Depth 3: [1, 3, 5, 7]
Return a list of lists of node values.
Hints
solution.py
Python ready
Test Output
▶
Click "Run Tests" to execute your code