This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

18
greed/11.h Normal file
View File

@@ -0,0 +1,18 @@
#include <math.h>
// 核心优化,每次移动较小的那个,因为移动较大的那个,面积只会越来越小
int maxArea(int* height, int heightSize) {
int left = 0;
int right = heightSize - 1;
int max = 0;
while(left < right){
max = fmax(max,(right-left)*fmin(height[left],height[right]));
if (height[left] < height[right])
{
left++;
}else{
right--;
}
}
return max;
}