更新双指针
This commit was merged in pull request #1.
This commit is contained in:
@@ -18,7 +18,7 @@ func trap(height []int) int {
|
||||
}
|
||||
if height[leftP] > height[rightP] {
|
||||
midres += height[leftP] - height[rightP]
|
||||
fmt.Println("result加上:", height[leftP]-height[rightP], "当前左指针:", leftP, "当前右指针:", rightP)
|
||||
fmt.Println("result加上:", height[leftP]-height[rightP], "当前1左指针:", leftP, "当前右指针:", rightP)
|
||||
rightP++
|
||||
} else if height[leftP] <= height[rightP] && midres != 0 {
|
||||
result += midres
|
||||
|
||||
Reference in New Issue
Block a user