11. 盛最多水的容器
func maxArea(height []int) int {
res := 0
i := 0
j := len(height)-1
for i<j {
dif := j-i
if height[i]<height[j] {
res = max(res, dif * height[i])
i++
} else {
res = max(res, dif * height[j])
j--
}
}
return res
}
func max(a,b int) int {
if a>b {
return a
}
return b
}

浙公网安备 33010602011771号