Skip to content

Practice Convert Sorted Array to Binary Search Tree

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#108
LeetCode Problem

Convert Sorted Array to Binary Search Tree

Problem Statement

Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.

Source: Convert Sorted Array to Binary Search Tree on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [-10,-3,0,5,9]
Output
[0,-3,9,-10,null,5]

# Example 2

Input
nums = [1,3]
Output
[3,1]

Constraints

1 <= nums.length <= 10^4
-10^4 <= nums[i] <= 10^4
nums is sorted in a strictly increasing order.

Related LeetCode Problems

Practice more problems similar to Convert Sorted Array to Binary Search Tree.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.