修改目录名称
This commit is contained in:
25
双指针/盛最多的水/main.go
Normal file
25
双指针/盛最多的水/main.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user