8ms:

```
class Solution {
private:
TreeNode* biggest(TreeNode* root){
if(!root->right) return root;
return biggest(root->right);
}
public:
void flatten(TreeNode* root) {
if(!root) return;
if(root->left){
TreeNode* tmp = biggest(root->left);
tmp->right = root->right;
root->right = root->left;
root->left = NULL;
}
flatten(root->right);
}
};
```

12ms:

```
class Solution {
public:
void flatten(TreeNode* root) {
if(!root) return;
if(root->left){
TreeNode* tmp = root->left;
while(tmp->right) {
tmp = tmp->right;
}
tmp->right = root->right;
root->right = root->left;
root->left = NULL;
}
flatten(root->right);
}
};
```