DFS with Left and Right Value

We often need to collect values from left subtree and right subtree then do something with them

In this case, we need to get the sum of all left leaf node

  • if not node, return 0

  • if it is a leaf node, append the node's value to a variable

  • if it is not a leaf node, we still need to search subtree

Last updated