Round 1
Questions: I was asked to convert a binary tree to a BST.
For my first approach, I explained taking the values into a vector, sorting them, and creating a new tree.
When asked to optimize for space, I suggested updating the tree's values in-place during an inorder traversal.
However, when asked to further optimize space, I was not able to further optimize.
Can anyone share the optimized approach in terms of space and time complexity?
Candidate's Approach
- First approach: Collect values in a vector, sort them, and create a new tree.
- Second approach: Update the tree's values in-place during an inorder traversal.
Interviewer's Feedback
No feedback provided.