代码如下:
class Solution {
public:
bool isSameTree(TreeNode* m, TreeNode* n)
{
if (!m && !n)
return true;
if (m && n)
{
if (m ->val != n ->val)
return false;
else
return isSameTree(m ->left, n ->left) && isSameTree(m ->right, n ->right);
}
return false;
}
};