Convert a Sorted Doubly Linked List to an In-Place Balanced BST

Given a doubly linked list sorted in nondecreasing order, with nodes:

Node:
  val
  prev
  next

Convert it in place into a height-balanced binary search tree (BST).

  • Do not allocat...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: