Algorithm · Salesforce · Medium
You are given the head of a doubly linked list whose nodes are sorted in non‑decreasing order. Each node stores an integer val, a prev pointer and a next pointer. Your task is to reshape this list in‑place into a height‑balanced binary search tree (BST). A BST is height‑balanced if, for every node, the depths of its left and right subtrees differ by at most 1. You must reuse the existing nodes without allocating any new ones: the prev field becomes the left child and next…
Checking your access…