
递归判断两个二叉树的节点值是否相同,代码特别简单。
100. Same Tree
Given two binary trees, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical and the nodes have the same value.
Example 1:
1 |
Input: 1 1 |
Example 2:
1 |
Input: 1 1 |
Example 3:
1 |
Input: 1 1 |
1 |
public boolean (TreeNode p, TreeNode q) { |




近期评论