public class Solution {
public boolean HasSubtree(TreeNode root1,TreeNode root2) { boolean ret = false; if(root1 == null || root2 == null) return ret; ret = helper(root1,root2); if(!ret) ret = helper(root1.left,root2); if(!ret) ret = helper(root1.right,root2); return ret; } public boolean helper(TreeNode root1, TreeNode root2) { if(root2==null) return true; if(root1==null) return false; if(root1.val != root2.val) return false; return helper(root1.left, root2.left) && helper(root1.right, root2.right); } }