标签:sam public lse als val amp cpp pre node
class Solution { public: bool isSameTree(TreeNode* p, TreeNode* q) { return dfs(p, q); } bool dfs(TreeNode *pt, TreeNode *qt) { if(pt == NULL && qt == NULL) return true; if(pt == NULL && qt != NULL) return false; if(pt != NULL && qt == NULL) return false; return (pt->val == qt->val) && dfs(pt->left, qt->left) && dfs(pt->right, qt->right); } };
标签:sam public lse als val amp cpp pre node
原文地址:https://www.cnblogs.com/yangwenhuan/p/12448006.html