标签:
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { public: void link(TreeNode *root,TreeNode** last) { if(!root) return ; TreeNode* cur=root; if(cur->left) link(cur->left,last); cur->left=*last; if((*last)!=NULL) (*last)->right=cur; *last=cur; if(cur->right) link(cur->right,last); } TreeNode* Convert(TreeNode* pRootOfTree) { TreeNode * last=NULL; link(pRootOfTree,&last); while(last!=NULL&&last->left!=NULL) last=last->left; return last; } };
标签:
原文地址:http://www.cnblogs.com/daocaorenblog/p/5374935.html