Here is the code I wrote:

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

};

and here is the output info:

Input:

{1,2,3}

Output:

{1,#,3}

Expected:

{1,#,2,#,3}

What seems to be the problem? I can't figure out.