Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f540b37

Browse files
committed
solved: container with most water
1 parent 0a23cb4 commit f540b37

File tree

3 files changed

+71122
-0
lines changed

3 files changed

+71122
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,29 @@ bool isMatch(String s, String p) {
6666
final RegExp regExp = RegExp(p);
6767
return regExp.stringMatch(s) == s;
6868
}
69+
```
70+
71+
### Container with most water
72+
73+
```dart
74+
int maxArea(List<int> height) {
75+
int max = 0;
76+
77+
int left = 0;
78+
int right = height.length - 1;
79+
80+
while (left < right) {
81+
final res = min(height[left], height[right]) * (right - left);
82+
83+
if (res > max) max = res;
84+
85+
if (height[left] < height[right]) {
86+
left++;
87+
} else {
88+
right--;
89+
}
90+
}
91+
92+
return max;
93+
}
6994
```

0 commit comments

Comments
 (0)