26 lines
339 B
Go
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
|
||
|
|
}
|