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.
1 parent dd4c423 commit b33c397Copy full SHA for b33c397
solution/0011.Container With Most Water/Solution.go
@@ -0,0 +1,30 @@
1
+func maxArea(height []int) int {
2
+ maxArea := 0
3
+ i := 0
4
+ j := len(height) - 1
5
+ for i != j {
6
+ hi := height[i]
7
+ hj := height[j]
8
+ maxArea = maxInt(maxArea, (j-i) * minInt(hi, hj))
9
+ if hi >= hj {
10
+ j--
11
+ } else {
12
+ i++
13
+ }
14
15
+ return maxArea
16
+}
17
+
18
+func minInt(a, b int) int {
19
+ if a >= b {
20
+ return b
21
22
+ return a
23
24
25
+func maxInt(a, b int) int {
26
27
28
29
30
0 commit comments