摘要:
TreeNode* flat(TreeNode *root) { if(!root) return NULL; TreeNode *tail1 = flat(root->left); TreeNode *tail2 = flat(root->right); if(tail1) { tail1->right = root->right; tail1->left = NULL; root->right = root->left;... 阅读全文
摘要:
int _maxDepthH(TreeNode *root,int curDepth) { if(!root) return curDepth; curDepth++; if(!root->left&&!root->right) return curDepth; int d1 = _maxDepthH(root->left,curDepth); int d2 = _maxDepthH(root->right,curDepth); return (d1>d2)?d... 阅读全文
摘要:
void helper(TreeNode *root,unsigned int curDepth,unsigned int *minDepth) { if(curDepth>=*minDepth-1) return; curDepth++; if(!root->left&&!root->right) { *minDepth = curDepth; return; }else { if(root->left) ... 阅读全文