Golang | Leetcode Golang题解之第11题盛最多水的容器

题目:

题解:

Go 复制代码
func maxArea(height []int) int {
    res := 0
    L := 0
    R := len(height) - 1
    for L < R {
        tmp := math.Min(float64(height[L]), float64(height[R]))
        res = int(math.Max(float64(res), tmp * float64((R - L))))
        if height[L] < height[R] {
            L++
        } else {
            R--
        }
    }
    return res
}
相关推荐
fqq34 小时前
力扣刷题前置Java语法
算法·leetcode·职场和发展
半夏微凉半夏殇6 小时前
x11与weston对比,优先选哪个
leetcode·均值算法·eclipse
爱编程的小新☆11 小时前
【LeetCode】从递归到 Flood Fill:5 道题吃透 DFS 的选择、回溯与标记
java·算法·leetcode·深度优先·回溯·flood fill
evans在进步12 小时前
LeetCode 33:搜索旋转排序数组——Java 两阶段二分查找详解
java·python·leetcode
alphaTao12 小时前
LeetCode 每日一题 2026/8/10-2026/8/16
算法·leetcode
Forever Nore13 小时前
LeetCode 13 罗马数字转整数 - 按规则处理
linux·服务器·leetcode
旖旎夜光14 小时前
LeetCode 904:水果成篮(滑动窗口) —— 题解
数据结构·c++·算法·leetcode·滑动窗口
ZC跨境爬虫15 小时前
LeetCode 27. 移除元素(双指针详解 + Java Python 多解法对比)
java·python·leetcode
圣殿骑士-Khtangc16 小时前
Go错误处理最佳实践进阶从error到panic的完整指南
golang
运维开发笔记17 小时前
3.6 Go defer 语句学习笔记
golang