Delete Nodes and Return the Resulting Forest

Given the root of a binary tree and a set of node values to_delete, delete every node whose value belongs to to_delete.

When a node is deleted:

  • Its non-null children are not deleted automatica...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: