Skip to content

Commit b4ae3cc

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2b5eb37 + 8da8f07 commit b4ae3cc

File tree

1 file changed

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

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

33
import com.fishercoder.common.classes.ListNode;
4+
import java.util.HashMap;
5+
import java.util.Map;
46

57
public class _24 {
68
public static class Solution1 {
@@ -24,17 +26,28 @@ public static class Solution2 {
2426
* Iterative approach:
2527
* My completely original on 10/24/2021.
2628
*/
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+
2737
public ListNode swapPairs(ListNode head) {
2838
ListNode pre = new ListNode(-1);
2939
pre.next = head;
3040
ListNode tmp = pre;
3141
while (head != null) {
42+
branchCoverage.put("flag1", true);
3243
ListNode third;
3344
ListNode first = head;
3445
ListNode second = head.next;
3546
if (second == null) {
47+
branchCoverage.put("flag2", true);
3648
break;
3749
} else {
50+
branchCoverage.put("flag3", true);
3851
third = head.next.next;
3952
second.next = first;
4053
first.next = third;
@@ -43,8 +56,14 @@ public ListNode swapPairs(ListNode head) {
4356
}
4457
head = third;
4558
}
59+
printCoverage();
4660
return pre.next;
4761
}
48-
}
4962

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+
}
5069
}

0 commit comments

Comments
 (0)