[LeetCode] (366) Find Leaves of Binary Tree

Source

Basic Idea: since we strip one layer of leaves at a time, the time when a middle node got stripped is based on the height of its taller children as the taller the children, the later the node got striped. Using a default dictionary, store a list of node values for each height, and construct the solution at the end.

Related posts