We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 580725d + edbc922 commit 52bdc09Copy full SHA for 52bdc09
go/11-Container-with-Most-Water.go
@@ -0,0 +1,28 @@
1
+func maxArea(height []int) int {
2
+ left := 0
3
+ right := len(height) - 1
4
+ res := 0
5
+
6
+ for left < right {
7
+ area := min(height[left], height[right]) * (right - left)
8
9
+ if area > res {
10
+ res = area
11
+ }
12
13
+ if height[left] > height[right] {
14
+ right--
15
+ } else {
16
+ left++
17
18
19
20
+ return res
21
+}
22
23
+func min(a, b int) int {
24
+ if a < b {
25
+ return a
26
27
+ return b
28
0 commit comments