力扣盛最多水的容器
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/cf12912eab038caee21838a9152f3a8c.png)
package doublepointer
func MaxArea(height []int) int {
maxWater := 0
startIndex := 0
endIndex := len(height) - 1
for startIndex < endIndex {
leftHeight := height[startIndex]
rightHeight := height[endIndex]
height := whatMin(leftHeight, rightHeight)
long := endIndex - startIndex
maxWater = whatMax(maxWater, long*height)
if leftHeight < rightHeight {
startIndex++
} else {
endIndex--
}
}
return maxWater
}
func whatMax(value1 int, value2 int) int {
if value1 > value2 {
return value1
}
return value2
}
func whatMin(value1 int, value2 int) int {
if value1 < value2 {
return value1
}
return value2
}