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
No.1
Input:
1 | 1 1 |
Output: true
No.2
Input:
1 | 1 1 |
Output: false
No.3
Input:
1 | 1 1 |
Output: false
Code
1 | public class TreeNode { |
1 | public boolean isSameTree(TreeNode p, TreeNode q) { |