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 afecf62 commit 4158189Copy full SHA for 4158189
container-with-most-water/yeonguchoe.cs
@@ -0,0 +1,22 @@
1
+using System;
2
+
3
+public class Solution {
4
+ public int MaxArea(int[] height) {
5
+ int currentMax = int.MinValue;
6
+ int leftPtr = 0;
7
+ int rightPtr = height.Length - 1;
8
9
+ while (leftPtr < rightPtr) {
10
+ int currentAmount = (rightPtr - leftPtr) * Math.Min(height[leftPtr], height[rightPtr]);
11
+ currentMax = Math.Max(currentMax, currentAmount);
12
13
+ if (height[leftPtr] < height[rightPtr]) {
14
+ leftPtr++;
15
+ } else {
16
+ rightPtr--;
17
+ }
18
19
20
+ return currentMax;
21
22
+}
0 commit comments