Code RoomMinimum BST height
MediumPrep Room Coding #126

Minimum BST height

CodingAlgorithms & data structuresMid–Senior~20 min

Given a strictly increasing sorted array `sorted_vals`, you may build a binary search tree from it by repeatedly choosing a value as the root and recursing on the left and right halves. Return the minimum possible height of such a BST, where height is the number of nodes on the longest root-to-leaf path (an empty tree has height 0, a single node has height 1). `0 <= len(sorted_vals) <= 100000`.

Implement
balanced_bst_height(sorted_vals: list[int]) → int
Examples
in[[1,2,3,4,5,6,7]]out3
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 20 min
InputExpectedGot
[[1,2,3,4,5,6,7]]3not run yetsample