题解 | #牛舍的占地面积#
牛舍的占地面积
https://www.nowcoder.com/practice/4d9d9bf23d874688aee6fc1ac5bf6902
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param areas int整型vector * @return int整型 */ int maxArea(vector<int>& areas) { int result = 0; for (int i = 0; i < areas.size(); ++i) { int minHeight = areas[i]; for (int j = i; j < areas.size(); ++j) { minHeight = min(minHeight, areas[j]); int temp = (j - i + 1) * minHeight; result = max(result, temp); } } return result; } };