Check whether tree1 has complete structure of tree2
0
$begingroup$
As title described, the code is written to solve the problem. public class Main { public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } public boolean HasSubtree(TreeNode root1,TreeNode root2) { if(root2 == null) { return true; } if(root1 == null) { return false; } if(root1.val == root2.val) { return HasSubtree(root1.left, root2.left) && HasSubtree(root1.right, root2.right); }else { return HasSubtree(root1.left, root2) || HasSubtree(root1.right, root2); } } } The algorithm I used can't pass online judgement, where...