Leetcode 366. Find Leaves of Binary Tree
- Type: Binary tree (bottom-up)
- Approach:
- The problem can be considered as find the height of each node.
- Thus, use bottom-up method to caculate each node height, which is max(left_height, right_height)+1
- Base case is when node is None, return 0.
- Complexity:
- Time: O(n)
- Space: O(n)