# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
#
#
# @param pRootOfTree TreeNode类
# @return TreeNode类
#
class Solution:
def Convert(self , pRootOfTree ):
# write code here
# 双向链表需要两个指针; 二叉搜索树递增序列需要采用中序遍历;
def recur(root):
if not root:
return
recur(root.left)
if self.pre:
root.left, self.pre.right = self.pre, root
else:
self.head = root
self.pre = root
recur(root.right)
if not pRootOfTree:return
cur = pRootOfTree
self.pre = None
recur(cur)
return self.head