1 class Solution { 2 public: 3 TreeLinkNode* GetNext(TreeLinkNode* pNode) 4 { 5 if(pNode == NULL ) 6 return NULL; 7 TreeLinkNode *p= NULL; 8 if(pNode->right == NULL) 9 { 10 p = pNode; 11 while(p->next && p != p->next->left) 12 { 13 p = p->next; 14 } 15 16 return p->next; 17 } 18 else 19 { 20 p = pNode->right; 21 while(p->left != NULL) 22 p = p->left; 23 } 24 return p; 25 } 26 };
时间: 2024-11-11 23:51:26