标签:style als return == code com iss || structure
解析:https://leetcode-cn.com/problems/shu-de-zi-jie-gou-lcof/solution/mian-shi-ti-26-shu-de-zi-jie-gou-xian-xu-bian-li-p/
bool isSubStructure(TreeNode* A, TreeNode* B) { //借用评论区和题解,用先序遍历A每个结点,判断它是否包含B的子树 if(A==NULL||B==NULL) return false; return bianli(A,B)||isSubStructure(A->left,B)||isSubStructure(A->right,B); } bool bianli(TreeNode* A,TreeNode* B){//判断每个结点 if(B==NULL) return true; if(A==NULL) return false; if(A->val!=B->val) return false; return bianli(A->left,B->left)&&bianli(A->right,B->right); }
标签:style als return == code com iss || structure
原文地址:https://www.cnblogs.com/Hello-Vivi/p/13603955.html