记住:二叉搜索树的中序遍历就是排序后的节点顺序!(做着做着就忘了这个很重要的点)
public class Solution { private TreeNode list = null, listHead = null; public TreeNode Convert(TreeNode pRootOfTree) { if (pRootOfTree == null) { return null; } Convert(pRootOfTree.left); if (list == null) { list = pRootOfTree; listHead = list; } else { list.right = pRootOfTree; pRootOfTree.left = list; list = pRootOfTree; } Convert(pRootOfTree.right); return listHead; } }