Given an array of integers heights representing the histogram’s bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.

classSolution { public: intlargestRectangleArea(std::vector<int>& heights){ heightSize = heights.size(); max = 0; for (int i = 0; i < heightSize; ++i) { int area = expandArea(heights, i); if (area > max) max = area; } return max; }

private: int heightSize = 0; int max = 0; intexpandArea(const std::vector<int>& heights, constint index){ int left = index; int right = index;

while (left - 1 >= 0) { if (heights[left - 1] >= heights[index]) { left--; continue; } break; }

while (right + 1 < heightSize) { if (heights[right + 1] >= heights[index]) { right++; continue; } break; }

classSolution { public: intlargestRectangleArea(std::vector<int>& heights){ int heightSize = heights.size(); int max = 0; auto leftBorders = std::vector<int>(heightSize); auto rightBorders = std::vector<int>(heightSize); int cur = 0;