【second】Flatten Binary Tree to Linked List
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                【second】Flatten Binary Tree to Linked List
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                遞歸
void flatten(TreeNode *root) {// Note: The Solution object is instantiated only once and is reused by each test case.flat(root);}TreeNode* flat(TreeNode* root){if(!root)return NULL;TreeNode* left_tail = flat(root->left);TreeNode* right_tail = flat(root->right);if(left_tail){left_tail->right = root->right;root->right = root->left;root->left = NULL;}if(right_tail)return right_tail;if(left_tail)return left_tail;return root;}
轉載于:https://www.cnblogs.com/summer-zhou/p/3384764.html
總結
以上是生活随笔為你收集整理的【second】Flatten Binary Tree to Linked List的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        