100. 相同的树
作者:互联网
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */ 10 class Solution 11 { 12 public: 13 bool isSameTree(TreeNode* p, TreeNode* q) 14 { 15 if(!p && !q) return true; 16 if(!p || !q) return false; 17 if(p->val != q->val) return false; 18 return isSameTree(p->left,q->left) && isSameTree(p->right,q->right); 19 } 20 };
标签:right,return,相同,val,isSameTree,TreeNode,100,left 来源: https://www.cnblogs.com/yuhong1103/p/12611818.html