一、题目内容
二、题解
解法1:
思路
代码
public class Solution { public boolean isContains (TreeNode root1, TreeNode root2) { // write code here if(root1 == null){ return false; } if(root1.val!=root2.val){ return isContains(root1.left,root2) || isContains(root1.right,root2); }else{ return isSame(root1,root2); } } private boolean isSame(TreeNode root1, TreeNode root2){ if(root1 == null&&root2==null){ return true; } if(root1==null||root2==null){ return false; } return (root1.val == root2.val) && isSame(root1.left,root2.left) && isSame(root1.right,root2.right); }}