containsOne(node)
that returns True
if the subtree rooted at node
contains a 1
, and False
otherwise.node
is null
, return False
.containsOne(node.left)
and containsOne(node.right)
to check the left and right subtrees.1
, prune it by setting node.left
to null
.1
, prune it by setting node.right
to null
.True
if the current node
's value is 1
or if either the left or right subtree contains a 1
.containsOne(root)
from the main function pruneTree
and return the potentially modified root
.