树的子结构

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);   } }

 

上一篇:jQuery MiniUI开发系列之:创建组件对象


下一篇:PHP ini_set() 函数