Skip to content

Latest commit

 

History

History
9 lines (9 loc) · 403 Bytes

note0366.md

File metadata and controls

9 lines (9 loc) · 403 Bytes
  • 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)