题目
https://leetcode-cn.com/problems/increasing-order-search-tree/
代码
class Solution {
TreeNode pre;
public TreeNode increasingBST(TreeNode root) {
TreeNode tmp=new TreeNode(-1);
pre=tmp;
dfs(root);
return tmp.right;
}
public void dfs(TreeNode root){
if(root==null){
return;
}
dfs(root.left);
pre.right=root;
root.left=null;
pre=root;
dfs(root.right);
}
}