image_2021-11-25_13-24-04.png
40.7 KB
#N897. Increasing Order Search Tree
problem link
#solution
problem link
#solution
class Solution {
TreeNode res = new TreeNode();
TreeNode curr=res;
public TreeNode increasingBST(TreeNode root) {
inOrder(root);
return res.right;
}
public void inOrder(TreeNode root){
if(root == null) return;
inOrder(root.left);
curr.right = new TreeNode(root.val);
curr = curr.right;
inOrder(root.right);
}
}