Skip to content

Commit 877563f

Browse files
committed
ava function 11
1 parent 8da8f07 commit 877563f

File tree

1 file changed

+20
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package com.fishercoder.solutions;
2+
import java.util.HashMap;
3+
import java.util.Map;
24

35
public class _11 {
46
public static class Solution1 {
@@ -23,21 +25,39 @@ public static class Solution2 {
2325
* Two pointer technique.
2426
* Well explained here: https://leetcode.com/problems/container-with-most-water/discuss/6100/Simple-and-clear-proofexplanation
2527
*/
28+
private static Map<String, Boolean> branchCoverage = new HashMap<>();
29+
30+
static {
31+
branchCoverage.put("flag1", false);
32+
branchCoverage.put("flag2", false);
33+
branchCoverage.put("flag3", false);
34+
}
35+
2636
public int maxArea(int[] height) {
2737
int max = 0;
2838
int left = 0;
2939
int right = height.length - 1;
3040
while (left < right) {
41+
branchCoverage.put("flag1", true);
3142
max = Math.max(Math.min(height[left], height[right]) * (right - left), max);
3243
if (height[left] <= height[right]) {
3344
/**if this height is shorter, then we'll need to move it to the right to find a higher one so that it's possible to find a larger area.*/
45+
branchCoverage.put("flag2", true);
3446
left++;
3547
} else {
48+
branchCoverage.put("flag3", true);
3649
right--;
3750
}
3851
}
52+
printCoverage();
3953
return max;
4054
}
55+
56+
public void printCoverage() {
57+
for (Map.Entry<String, Boolean> entry : branchCoverage.entrySet()) {
58+
System.out.println(entry.getKey() + " was " + (entry.getValue() ? "hit" : "not hit"));
59+
}
60+
}
4161
}
4262

4363
}

0 commit comments

Comments
 (0)