cKK

............当你觉得自己很辛苦,说明你正在走上坡路.............坚持做自己懒得做但是正确的事情,你就能得到别人想得到却得不到的东西............

导航

100. Same Tree(Tree)

Posted on 2016-02-16 23:27  cKK  阅读(106)  评论(0编辑  收藏  举报
/**
 * 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 p=q;
        return(p.val==q.val && isSameTree(p.left,q.left) && isSameTree(p.right,q.right));
    }
}