Skip to content

Commit 9e9d88a

Browse files
update 11
1 parent 9e1aceb commit 9e9d88a

2 files changed

Lines changed: 0 additions & 20 deletions

File tree

  • src
    • main/java/com/fishercoder/solutions/firstthousand
    • test/java/com/fishercoder/firstthousand

src/main/java/com/fishercoder/solutions/firstthousand/_11.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@
22

33
public class _11 {
44
public static class Solution1 {
5-
/*
6-
* Time: O(n^2)
7-
* This brute force solution is NOT accepted on LeetCode due to TLE.
8-
*/
9-
public int maxArea(int[] height) {
10-
int maxArea = 0;
11-
for (int left = 0; left < height.length - 1; left++) {
12-
for (int right = height.length - 1; left < right; right--) {
13-
int area = (right - left) * Math.min(height[left], height[right]);
14-
maxArea = Math.max(maxArea, area);
15-
}
16-
}
17-
return maxArea;
18-
}
19-
}
20-
21-
public static class Solution2 {
225
/*
236
* Two pointer technique.
247
* Well explained here: https://leetcode.com/problems/container-with-most-water/discuss/6100/Simple-and-clear-proofexplanation

src/test/java/com/fishercoder/firstthousand/_11Test.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@
88

99
public class _11Test {
1010
private _11.Solution1 solution1;
11-
private _11.Solution2 solution2;
1211
private static int[] height;
1312
private static int expected;
1413

1514
@BeforeEach
1615
public void setup() {
1716
solution1 = new _11.Solution1();
18-
solution2 = new _11.Solution2();
1917
}
2018

2119
@Test
2220
public void test1() {
2321
height = new int[] {1, 1};
2422
expected = 1;
2523
assertEquals(expected, solution1.maxArea(height));
26-
assertEquals(expected, solution2.maxArea(height));
2724
}
2825
}

0 commit comments

Comments
 (0)