[LeetCode] 11. Container With Most Water
class Solution {
func maxArea(_ height: [Int]) -> Int {
var left = 0;
var right = height.count - 1;
var output = 0;
while(left < right) {
var value = 0;
if(height[left] > height[right]) {
value = (right - left) * height[right];
right -= 1;
}
else {
value = (right - left) * height[left];
left += 1;
}
output = max(output, value);
}
return output;
}
}Last updated