Untitled
unknown
plain_text
10 months ago
435 B
4
Indexable
class Solution {
TreeNode cur;
public TreeNode increasingBST(TreeNode root) {
TreeNode dummy = new TreeNode(0);
cur = dummy;
inorder(root);
return dummy.right;
}
public void inorder(TreeNode node) {
if (node == null) return;
inorder(node.left);
node.left = null;
cur.right = node;
cur = node;
inorder(node.right);
}
}Editor is loading...
Leave a Comment