@@ -0,0 +1,1101 @@
+package com.matao.Q18;%0A%0Aimport com.matao.common.TreeNode;%0A%0A/**%0A * Created by matao on 10/26/16.%0A * %3Cp%3E%0A * %E8%BE%93%E5%85%A5%E4%B8%A4%E9%A2%97%E4%BA%8C%E5%8F%89%E6%A0%91A%E5%92%8CB%EF%BC%8C%E5%88%A4%E6%96%ADB%E6%98%AF%E4%B8%8D%E6%98%AFA%E7%9A%84%E5%AD%90%E7%BB%93%E6%9E%84%0A */%0Apublic class HasSubtree %7B%0A%0A    public static boolean hasSub(TreeNode root1, TreeNode root2) %7B%0A        boolean result = false;%0A        if (root1 != null && root2 != null) %7B%0A            if (root1.val == root2.val) %7B%0A                result = hasSub(root1, root2);%0A            %7D%0A            if (!result) %7B%0A                result = hasSub(root1.left, root2.left);%0A            %7D%0A            if (!result) %7B%0A                result = hasSub(root1.right, root2.right);%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static boolean tree1HasTree2(TreeNode root1, TreeNode root2) %7B%0A        if (root2 == null) %7B%0A            return true;%0A        %7D%0A%0A        if (root1 == null) %7B%0A            return false;%0A        %7D%0A%0A        if (root1.val != root2.val) %7B%0A            return false;%0A        %7D%0A%0A        return tree1HasTree2(root1.left, root2.left)%0A                && tree1HasTree2(root1.right, root2.right);%0A%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A    %7D%0A%7D%0A

Add Q18