#include <algorithm> #include <vector> class MinimalBST { int build(const vector<int> &vals, int left, int right){ if(left > right) return 0; int root_ind = left + (right - left) /2; int left_h = build(vals, left, root_ind-1); int right_h = build(vals, root_ind+1, right); return 1+ max(left_h, right_h ); } public: int buildMinimalBST(vector<int> vals) { // write code here return build(vals, 0, vals.size() -1); } };