package GeeksforGeeksPractice;

public class _0018BinaryTreeSubTreeCheck {
	public static class TreeNode {
		int val;
		TreeNode left;
		TreeNode right;
		TreeNode(int x) { val = x; }
	}
	public static void main(String args[]){
		TreeNode tn1=new TreeNode(10);
		tn1.left=new TreeNode(8);
		tn1.right=new TreeNode(2);
		tn1.left.left=new TreeNode(3);
		tn1.left.right=new TreeNode(5);
		tn1.right.left=new TreeNode(1);
		tn1.right.right=new TreeNode(30);
		TreeNode tn2=new TreeNode(2);
		tn2.left=new TreeNode(1);
		tn2.right=new TreeNode(30);
		System.out.println(checkBinarySubTree(tn1, tn2));

	}
	public static boolean checkBinarySubTree(TreeNode tn1,TreeNode tn2){
		return false;
	}

}

@@ -694,20 +694,617 @@
 %0D%0A%09%09
-return false
+tn1=getNode(tn1,tn2);%0D%0A%09%09return isSubTree(tn1,tn2);%0D%0A%09%7D%0D%0A%09private static boolean isSubTree(TreeNode tn1, TreeNode tn2) %7B%0D%0A%09%09if(tn1!=null && tn2!=null)%0D%0A%09%09%7B%0D%0A%09%09%09return tn1.val==tn2.val && isSubTree(tn1.left, tn2.left) && isSubTree(tn1.right, tn2.right);%0D%0A%09%09%7D%0D%0A%09%09return (tn1!=null %7C%7Ctn2!=null)?false:true;%0D%0A%09%7D%0D%0A%09private static TreeNode getNode(TreeNode tn1, TreeNode tn2) %7B%0D%0A%09%09if(tn1!=null)%7B%0D%0A%09%09%09if(tn1.val==tn2.val)%0D%0A%09%09%09%09return tn1;%0D%0A%09%09%09else%0D%0A%09%09%09%7B%0D%0A%09%09%09%09if(getNode(tn1.left, tn2)!=null)%0D%0A%09%09%09%09%7B%0D%0A%09%09%09%09%09return getNode(tn1.left, tn2);%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%09else%0D%0A%09%09%09%09%09return getNode(tn1.right, tn2);%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return null
 ;%0D%0A%09

Check binary sub tree completed