Tap here to switch tabs
Problem
Submissions

Problem: Convert Sorted List to Binary Search Tree

med
30 min
Try to solve the Convert Sorted List to Binary Search Tree problem.

Statement

Given the head of a singly linked list whose elements are arranged in ascending order, convert it into a height-balanced binary search tree and return the root of the resulting tree.

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

Constraints:

  • 0≤0 \leq number of nodes in head ≤2×104\leq 2 \times 10^4

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Convert Sorted List to Binary Search Tree

med
30 min
Try to solve the Convert Sorted List to Binary Search Tree problem.

Statement

Given the head of a singly linked list whose elements are arranged in ascending order, convert it into a height-balanced binary search tree and return the root of the resulting tree.

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

Constraints:

  • 0≤0 \leq number of nodes in head ≤2×104\leq 2 \times 10^4

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5