Increasing Order Search Tree
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given the root of a binary search tree with distinct values. Rearrange it so that the nodes form a single chain in ascending order: the smallest value becomes the new root, every node has **no left child**, and each node's right child is the next larger value.
Return the root of the rearranged tree. You may relink the existing nodes or build new ones; only the resulting shape and values are checked.
An in-order traversal visits the values in exactly the order the chain needs, so O(n) time is achievable.
Examples
Constraints
- 1 <= number of nodes <= 100
- 0 <= Node.val <= 1000
- All values are distinct and the input is a valid BST
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.