31. Delete Leaves With a Given Value
Given a binary tree root and an integer target, delete all the leaf nodes with value target.
Note that once you delete a leaf node with value target, if it's parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you can't).
Example 1:

Example 2:

Example 3:

Example 4:
Example 5:
Solution: (Postorder Traversal)
Last updated
Was this helpful?