/**
* 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;
else if (p!=null && q!=null && p.val== q.val)
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
return false;
}
}
leetcode 100. Same Tree
最新推荐文章于 2022-03-19 13:19:57 发布