(TreeNode p, TreeNode q)
| 13 | */ |
| 14 | public class Solution { |
| 15 | public boolean isSameTree(TreeNode p, TreeNode q) { |
| 16 | if (p == null || q == null) return p == q; |
| 17 | if (p.val != q.val) return false; |
| 18 | return isSameTree(p.left, q.left) && isSameTree(p.right, q.right); |
| 19 | } |
| 20 | |
| 21 | public static void main(String[] args) { |
| 22 | Solution solution = new Solution(); |