Search⌘ K
AI Features

Problem: Convert Sorted Array to Binary Search Tree

Understand the process of converting a sorted integer array into a height-balanced binary search tree (BST). Explore recursive techniques that select the middle element as the root to maintain balance, ensuring efficient search operations. Learn how to implement this using Java by dividing the array into subarrays for left and right subtrees and grasp the time and space complexity considerations.

Statement

You are given an integer array nums whose elements are sorted in strictly increasing order. Your task is to construct a height-balanced binary search tree (BST) from this array and return its root.

A height-balanced binary tree is one in which the depth of the two subtrees of every node never differs by more than 11.

Note: Multiple valid height-balanced BSTs may exist for a given input. Any valid answer will be accepted.

Constraints:

  • 11 \leq nums.length 104\leq 10^4

  • 104-10^4 \leq nums[i] 104 ...