feat: 2025-10-30打卡(接雨水)

This commit is contained in:
wu xiangkai
2025-10-30 14:47:22 +08:00
parent ea9dfb9d54
commit b897d019fa
3 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/*
* @lc app=leetcode id=11 lang=java
*
* [11] Container With Most Water
*/
// @lc code=start
class Solution {
public int maxArea(int[] height) {
int l = 0, r = height.length -1, max = 0;
while(l < r) {
max = Math.max(max, (r-l)*Math.min(height[l], height[r]));
if(height[l] < height[r]) {
l++;
} else {
r--;
}
}
return max;
}
}
// @lc code=end