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 74db2c7 commit fbff392Copy full SHA for fbff392
container-with-most-water/WhiteHyun.swift
@@ -0,0 +1,30 @@
1
+//
2
+// 11. Container With Most Water
3
+// https://leetcode.com/problems/container-with-most-water/description/
4
+// Dale-Study
5
6
+// Created by WhiteHyun on 2024/06/08.
7
8
+
9
+class Solution {
10
+ func maxArea(_ height: [Int]) -> Int {
11
+ var totalArea = 0
12
+ var left = 0
13
+ var right = height.endIndex - 1
14
15
+ while left < right {
16
+ let area = (right - left) * min(height[left], height[right])
17
+ if area > totalArea {
18
+ totalArea = area
19
+ }
20
21
+ if height[left] < height[right] {
22
+ left += 1
23
+ } else {
24
+ right -= 1
25
26
27
28
+ return totalArea
29
30
+}
0 commit comments