class Solution {
public:
void flatten(TreeNode
* root) {
if(root
== NULL){
return;
}
TreeNode
*temp
= root;
TreeNode
*left
= root
->left;
TreeNode
*right
= root
->right;
if(left
!= NULL){
temp
= left;
while(temp
->right
!= NULL){
temp
= temp
->right;
}
temp
->right
= right;
root
->right
= root
->left;
root
->left
= NULL;
}
flatten(root
->right);
}
};
转载请注明原文地址: https://www.6miu.com/read-29203.html