Files
Hot-100-Algorithm/双指针/盛最多的水/main.go
2025-08-19 03:50:15 +08:00

26 lines
339 B
Go

package main
func main() {
}
func maxArea(height []int) int {
left := 0
right := len(height) - 1
maxscore := 0
for left < right {
temp := min(height[left], height[right]) * (right - left)
if temp > maxscore {
maxscore = temp
}
if height[left] < height[right] {
left++
} else {
right--
}
}
return maxscore
}