From ca027e68fd236253b5772632f470b86a757bde2f Mon Sep 17 00:00:00 2001 From: mayiming <1627832236@qq.com> Date: Mon, 28 Jul 2025 19:09:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E9=9B=A8=E6=B0=B4=E9=A2=98=E8=A7=A3ha?= =?UTF-8?q?lf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TwoPointers/jieyushui/main.go | 31 +++++++++++++++++++++++++++++++ problem1/1.go | 5 ----- problem2/2.go | 5 ----- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 TwoPointers/jieyushui/main.go delete mode 100644 problem1/1.go delete mode 100644 problem2/2.go diff --git a/TwoPointers/jieyushui/main.go b/TwoPointers/jieyushui/main.go new file mode 100644 index 0000000..9df6745 --- /dev/null +++ b/TwoPointers/jieyushui/main.go @@ -0,0 +1,31 @@ +package main + +import "fmt" + +func main() { + resule := trap([]int{4, 2, 0, 3, 2, 5}) + fmt.Println("最大接水数为:", resule) +} + +func trap(height []int) int { + leftMaxlist := make([]int, len(height)+1) + rightMaxlist := make([]int, len(height)+1) + minMax := make([]int, len(height)+1) + for i := 0; i < len(height)-1; i++ { + leftMaxlist[i+1] = max(height[i], leftMaxlist[i]) + } + for i := len(height) - 1; i >= 0; i-- { + rightMaxlist[i] = max(height[i], rightMaxlist[i+1]) + } + fmt.Println(leftMaxlist) + fmt.Println(rightMaxlist) + for i := 0; i < len(minMax)-1; i++ { + minMax[i] = min(leftMaxlist[i], rightMaxlist[i]) + } + + for i := len(minMax) - 1; i >= 0; i-- { + + } + + return 0 +} diff --git a/problem1/1.go b/problem1/1.go deleted file mode 100644 index 8b4df07..0000000 --- a/problem1/1.go +++ /dev/null @@ -1,5 +0,0 @@ -package problem1 - -func main() { - -} diff --git a/problem2/2.go b/problem2/2.go deleted file mode 100644 index 5aad495..0000000 --- a/problem2/2.go +++ /dev/null @@ -1,5 +0,0 @@ -package problem2 - -func main() { - -}