标签:中序 item 描述 style == 遍历 ptr turn 情况
1 class Solution { 2 public: 3 TreeLinkNode* GetNext(TreeLinkNode* pNode) 4 { 5 if (pNode == nullptr) 6 return nullptr; 7 if (pNode->right != nullptr)//有右子树,则为右子树的最左节点 8 { 9 pNode = pNode->right; 10 while (pNode->left != nullptr) 11 pNode = pNode->left; 12 return pNode; 13 } 14 else if (pNode->right == nullptr) 15 { 16 while (pNode->next!=nullptr && pNode != pNode->next->left) 17 pNode = pNode->next; 18 return pNode->next; 19 } 20 return nullptr; 21 } 22 };
标签:中序 item 描述 style == 遍历 ptr turn 情况
原文地址:https://www.cnblogs.com/zzw1024/p/11651322.html