java.lang.Object
g1101_1200.s1110_delete_nodes_and_return_forest.Solution

public class Solution extends Object
1110 - Delete Nodes And Return Forest.<p>Medium</p> <p>Given the <code>root</code> of a binary tree, each node in the tree has a distinct value.</p> <p>After deleting all nodes with a value in <code>to_delete</code>, we are left with a forest (a disjoint union of trees).</p> <p>Return the roots of the trees in the remaining forest. You may return the result in any order.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2019/07/01/screen-shot-2019-07-01-at-53836-pm.png" alt="" /></p> <p><strong>Input:</strong> root = [1,2,3,4,5,6,7], to_delete = [3,5]</p> <p><strong>Output:</strong> [[1,2,null,4],[6],[7]]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> root = [1,2,4,null,3], to_delete = [3]</p> <p><strong>Output:</strong> <a href="1,2,4">1,2,4</a></p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in the given tree is at most <code>1000</code>.</li> <li>Each node has a distinct value between <code>1</code> and <code>1000</code>.</li> <li><code>to_delete.length <= 1000</code></li> <li><code>to_delete</code> contains distinct values between <code>1</code> and <code>1000</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details