class Solution {
public:
void flatten(TreeNode* root) {
while(root){
auto p=root->left;
if(p){
while(p->right) p=p->right;
p->right=root->right;
root->right=root->left;
root->left=NULL;
}
root=root->right;
}
}
};
03-14
1796
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-29
2097
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-30
268
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-30
211
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)