https://www.cnblogs.com/grandyang/p/4293853.html
/
5
/ \
4 6
/
4
\
\
\
\
\
\
class Solution {
public:
void flatten(TreeNode* root) {
if(root==NULL)return;
if(root->left)flatten(root->left);
if(root->right)flatten(root->right);
TreeNode*temp=root->right;
root->right=root->left;
root->left=NULL;
while(root->right)root=root->right;
root->right=temp;
}
};
网友评论