Delete Nodes And Return Forest at Meta

Medium72.5% acceptance

This problem has 25.0% frequency at Meta.

Problem Description

Given the `root` of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in `to_delete`, we are left with a forest (a disjoint union of trees). Return the roots of the trees in the remaining forest. You may return the result in any order.

Read full problem and hints

Topics

Also asked at 4 companies


More Meta Questions

View all Meta questions