Leetcode 1382. Balance a Binary Search Tree
Given a BST, produce any height-balanced BST containing the same node values (a tree where the depths of left and right subtrees of every node differ by at most 1). Key idea: use an inorder traversal to get the sorted values and rebuild the tree with a divide-and-conquer (middle-element as root) to ensure balance.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.