File tree 1 file changed +20
-1
lines changed
src/main/java/com/fishercoder/solutions 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
3
3
import com .fishercoder .common .classes .ListNode ;
4
+ import java .util .HashMap ;
5
+ import java .util .Map ;
4
6
5
7
public class _24 {
6
8
public static class Solution1 {
@@ -24,17 +26,28 @@ public static class Solution2 {
24
26
* Iterative approach:
25
27
* My completely original on 10/24/2021.
26
28
*/
29
+ private static Map <String , Boolean > branchCoverage = new HashMap <>();
30
+
31
+ static {
32
+ branchCoverage .put ("flag1" , false );
33
+ branchCoverage .put ("flag2" , false );
34
+ branchCoverage .put ("flag3" , false );
35
+ }
36
+
27
37
public ListNode swapPairs (ListNode head ) {
28
38
ListNode pre = new ListNode (-1 );
29
39
pre .next = head ;
30
40
ListNode tmp = pre ;
31
41
while (head != null ) {
42
+ branchCoverage .put ("flag1" , true );
32
43
ListNode third ;
33
44
ListNode first = head ;
34
45
ListNode second = head .next ;
35
46
if (second == null ) {
47
+ branchCoverage .put ("flag2" , true );
36
48
break ;
37
49
} else {
50
+ branchCoverage .put ("flag3" , true );
38
51
third = head .next .next ;
39
52
second .next = first ;
40
53
first .next = third ;
@@ -43,8 +56,14 @@ public ListNode swapPairs(ListNode head) {
43
56
}
44
57
head = third ;
45
58
}
59
+ printCoverage ();
46
60
return pre .next ;
47
61
}
48
- }
49
62
63
+ public void printCoverage () {
64
+ for (Map .Entry <String , Boolean > entry : branchCoverage .entrySet ()) {
65
+ System .out .println (entry .getKey () + " was " + (entry .getValue () ? "hit" : "not hit" ));
66
+ }
67
+ }
68
+ }
50
69
}
You can’t perform that action at this time.
0 commit comments