/*
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :
val(x), left(NULL), right(NULL) {
}
};*/
class Solution {
public:
TreeNode *t;
TreeNode* Convert(TreeNode* pRootOfTree) {
if(!pRootOfTree) return nullptr;
TreeNode *head = Convert(pRootOfTree->left);
if(!head) head = pRootOfTree;
pRootOfTree->left = t;
if(t)
t->right = pRootOfTree;
t = pRootOfTree;
Convert(pRootOfTree->right);
return head;
}
};