Tap here to switch tabs
Problem
Submissions

Problem: Balance a Binary Search Tree

Try to solve the Balance a Binary Search Tree problem.

Statement

Given the root of a binary search tree, return a balanced binary search tree containing the same node values. If there are multiple valid answers, return any of them.

Note: A binary search tree is balanced if the depth difference between the two subtrees of every node is at most 11.

Constraints:

  • The number of nodes in the tree is in the range [1,104][1, 10^4].

  • 1≤1 \leq Node.val ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Balance a Binary Search Tree

Try to solve the Balance a Binary Search Tree problem.

Statement

Given the root of a binary search tree, return a balanced binary search tree containing the same node values. If there are multiple valid answers, return any of them.

Note: A binary search tree is balanced if the depth difference between the two subtrees of every node is at most 11.

Constraints:

  • The number of nodes in the tree is in the range [1,104][1, 10^4].

  • 1≤1 \leq Node.val ≤105\leq 10^5