Leetcode 100. Same Tree
문제 : 100. Same Tree
등급 : Easy
class Solution {
public:
bool isSameTree(TreeNode* p, TreeNode* q) {
if (!p && !q)
return true;
if ((!p && q) || (p && !q))
return false;
if (p->val != q->val)
return false;
auto lcheck = isSameTree(p->left, q->left);
if (!lcheck)
return false;
auto rcheck = isSameTree(p->right, q->right);
if (!rcheck)
return false;
return true;
}
};