1. Use recursion to return values in a bottom-up way in binary tree, 从下往下返值

3 steps:

  1. what do you expect from your left child and right child?(usually it is thte return type of the recursion function)
  2. what do you want to do in the current layer?
  3. what do you want to report to your paren?

2. Path Problem in Binary Tree

Class1. 人字形path, 一般需要从下向上传value(Tree recursion 3 steps)

Class2: 从root 往下,(直上直下) path。 key points : to carry 直上直下 path prefix while traversing the tree

results matching ""

    No results matching ""