Code Room
CodingMediumcod-g069
Subject Balanced treesLevel Mid–Senior~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.