package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/delete-nodes-and-return-forest/
 */
public class Problem1110 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public List<TreeNode> delNodes(TreeNode root, int[] to_delete) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1110 prob = new Problem1110();
    }
}

@@ -29,19 +29,95 @@
 va.util.
-Lis
+ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Se
 t;%0A%0A/**%0A
@@ -457,15 +457,271 @@
     
-// TODO
+Set%3CInteger%3E toDelete = new HashSet%3C%3E();%0A        for (int delete : to_delete) %7B%0A            toDelete.add(delete);%0A        %7D%0A        List%3CTreeNode%3E answer = new ArrayList%3C%3E();%0A        if (!delNodes(root, toDelete, answer)) %7B%0A            answer.add(root);%0A        %7D
 %0A   
@@ -736,12 +736,14 @@
 urn 
-null
+answer
 ;%0A  
@@ -752,29 +752,30 @@
 %7D%0A%0A    p
-ublic
+rivate
  static 
 void mai
@@ -770,79 +770,662 @@
 tic 
-void main(String%5B%5D args) %7B%0A        Problem1110 prob = new Problem1110()
+boolean delNodes(TreeNode current, Set%3CInteger%3E toDelete, List%3CTreeNode%3E answer) %7B%0A        if (current == null) %7B%0A            return false;%0A        %7D%0A        boolean delete = toDelete.contains(current.val);%0A        if (delNodes(current.left, toDelete, answer)) %7B%0A            current.left = null;%0A        %7D%0A        if (delNodes(current.right, toDelete, answer)) %7B%0A            current.right = null;%0A        %7D%0A        if (delete) %7B%0A            if (current.left != null) %7B%0A                answer.add(current.left);%0A            %7D%0A            if (current.right != null) %7B%0A                answer.add(current.right);%0A            %7D%0A        %7D%0A        return delete
 ;%0A  

Solve problem 1110