/**
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
*/
public class Solution {
TreeNode cur =null;
TreeNode head=null;
public TreeNode Convert(TreeNode pRootOfTree) {
if(pRootOfTree==null){
return null;
}
Convert(pRootOfTree.left);
//最左边节点的,也就是最小节点
if(cur==null){
cur=pRootOfTree;
head=pRootOfTree;
}else{
cur.right=pRootOfTree;
pRootOfTree.left=cur;
cur=pRootOfTree;
}
Convert(pRootOfTree.right);
return head;
}
}
思路:二叉搜索树的常考点就是 进行中序遍历 ,中序遍历后可以得到有序数列,然后进行操作