#109
Convert Sorted List to Binary Search Tree
specialist · 610 · lc medium +29 · verified · 66.1% accepted · 7,856 likes · top 71%
Description
Given the head of a sorted singly linked list (values in ascending order), construct and return a height-balanced binary search tree.
Example 1:
Input: head = [-10,-3,0,5,9]
Output: [0,-3,9,-10,null,5]
Explanation: One possible answer is [0,-3,9,-10,null,5], which represents the shown height balanced BST.
Example 2:
Input: head = []
Output: []
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14