1
1
package com .fishercoder .solutions ;
2
+ import java .util .HashMap ;
3
+ import java .util .Map ;
2
4
3
5
public class _11 {
4
6
public static class Solution1 {
@@ -23,21 +25,39 @@ public static class Solution2 {
23
25
* Two pointer technique.
24
26
* Well explained here: https://leetcode.com/problems/container-with-most-water/discuss/6100/Simple-and-clear-proofexplanation
25
27
*/
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
+
26
36
public int maxArea (int [] height ) {
27
37
int max = 0 ;
28
38
int left = 0 ;
29
39
int right = height .length - 1 ;
30
40
while (left < right ) {
41
+ branchCoverage .put ("flag1" , true );
31
42
max = Math .max (Math .min (height [left ], height [right ]) * (right - left ), max );
32
43
if (height [left ] <= height [right ]) {
33
44
/**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 );
34
46
left ++;
35
47
} else {
48
+ branchCoverage .put ("flag3" , true );
36
49
right --;
37
50
}
38
51
}
52
+ printCoverage ();
39
53
return max ;
40
54
}
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
+ }
41
61
}
42
62
43
63
}
0 commit comments