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.
bool isSameTree(TreeNode* p, TreeNode* q) {
queue<TreeNode*> que;
que.push(p);
que.push(q);
while(!que.empty()){
p = que.front();
que.pop();
q = que.front();
que.pop();
if(!p && !q)
continue;
if(!p || !q || (p -> val != q -> val))
return false;
que.push(p -> left);
que.push(q -> left);
que.push(p -> right);
que.push(q -> right);
}
return true;
}