简单题 分治策略
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public boolean isSameTree(TreeNode p, TreeNode q) {
if(p==null&&q==null) return true;
if(p==null&&q!=null) return false;
if(q==null&&p!=null) return false;
if(p.val==q.val){
if(isSameTree(p.left,q.left)&&isSameTree(p.right,q.right)){
return true;
}else{
return false;
}
}else{
return false;
}
}
}