Skip to content

Commit 40de54e

Browse files
author
[irina.popovikj]
committed
irina added flags for 3.java
1 parent 6711711 commit 40de54e

File tree

1 file changed

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

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ public int lengthOfLongestSubstring(String s) {
7474
}
7575
}
7676

77+
private static Map<String, Boolean> branchCoverage = new HashMap<>();
78+
79+
static {
80+
branchCoverage.put("flag1", false);
81+
branchCoverage.put("flag2", false);
82+
}
83+
7784
public static class Solution4 {
7885
/**
7986
* Sliding Window Optimized
@@ -82,20 +89,31 @@ public static class Solution4 {
8289
*/
8390
public int lengthOfLongestSubstring(String s) {
8491
if (s.length() == 0) {
92+
branchCoverage.put("flag1", true);
8593
return 0;
8694
}
8795
int max = 0;
8896
int[] index = new int[128];
89-
/**Try to extend the range (i, j)*/
9097
for (int i = 0, j = 0; j < s.length(); j++) {
98+
branchCoverage.put("flag2", true);
9199
i = Math.max(index[s.charAt(j)], i);
92100
max = Math.max(max, j - i + 1);
93101
index[s.charAt(j)] = j + 1;
94102
}
103+
printCoverage();
95104
return max;
96105
}
106+
107+
public static void printCoverage() {
108+
for (Map.Entry<String, Boolean> entry : branchCoverage.entrySet()) {
109+
System.out.println(entry.getKey() + " was " + (entry.getValue() ? "hit" : "not hit"));
110+
}
111+
}
112+
97113
}
98114

115+
116+
99117
public static class Solution5 {
100118
/**
101119
* Sliding Window, my completely original idea on 9/17/2021.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy