Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
1 class Solution { 2 public boolean isSameTree(TreeNode p, TreeNode q) { 3 //base case 4 if(p==null || q==null) return p==null&& q==null; 5 //recursion 6 return p.val==q.val && isSameTree(p.left,q.left) && isSameTree(q.right,p.right); 7 } 8 }