100. Same Tree(Tree)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了100. Same Tree(Tree)相关的知识,希望对你有一定的参考价值。

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

  

以上是关于100. Same Tree(Tree)的主要内容,如果未能解决你的问题,请参考以下文章

100. Same Tree

100. Same Tree(Tree)

100. Same Tree(LeetCode)

100. Same Tree (Tree;DFS)

100. Same Tree (Tree)

Leetcode[100]-Same Tree