classSolution { public: intlargestRectangleArea(vector<int>& heights){ if (heights.size() == 0) return0; returncalArea(heights, 0, heights.size()-1); } intcalArea(vector<int> &heights, int start, int end){ if (start > end || start > heights.size()-1 || end < 0) return INT_MIN; int min_index = start; for (int i = start+1; i <= end; i++) { if (heights[i] < heights[min_index]) min_index = i; } int left = calArea(heights, start, min_index-1); int right = calArea(heights, min_index+1, end); returnmax(heights[min_index] * (end-start+1), max(left, right)); } };