Skip to content

Files

Latest commit

Jul 19, 2019
288277b · Jul 19, 2019

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 19, 2019
Jul 19, 2019

Given a binary tree where all nodes are either 0 or 1, prune the tree so that subtrees containing all 0s are removed.

For example, given the following tree:

   0
  / \
 1   0
    / \
   1   0
  / \
 0   0

should be pruned to:

   0
  / \
 1   0
    /
   1

We do not remove the tree at the root or its left child because it still has a 1 as a descendant.