Minimum BST height
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]) → intExamples
in
[[1,2,3,4,5,6,7]]out3What 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
solution.py
InputExpectedGot
[[1,2,3,4,5,6,7]]3not run yetsample