Find Leaves of Binary Tree
ID: 650; medium; 二叉树叶子顺序遍历
Last updated
Was this helpful?
ID: 650; medium; 二叉树叶子顺序遍历
Last updated
Was this helpful?
Use a HashMap
to store the levels of the tree. The key is the level (1 is the bottom level) and the value of a list of node values.
Use a similar mechanism in Maximum Depth of Binary Tree and add a few operations to populate the map.
Lastly, convert the values in the map to a result list and return.