Skip to content

Commit 2b5eb37

Browse files
committed
Added Flags to file 58 solution 1
1 parent 1d82f14 commit 2b5eb37

File tree

1 file changed

+17
-2
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+17
-2
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
package com.fishercoder.solutions;
2+
import java.util.HashMap;
3+
import java.util.Map;
24

35
public class _58 {
4-
56
public static class Solution1 {
7+
private static Map<String, Boolean> branchCoverage = new HashMap<>();
8+
9+
static {
10+
branchCoverage.put("flag1", false);
11+
branchCoverage.put("flag2", false);
12+
}
13+
614
public int lengthOfLastWord(String s) {
715
if (s == null || s.length() == 0) {
16+
branchCoverage.put("flag1", true);
817
return 0;
918
}
1019
s = s.trim();
1120
int n = s.length() - 1;
1221
while (n >= 0 && s.charAt(n) != ' ') {
22+
branchCoverage.put("flag2", true);
1323
n--;
1424
}
25+
printCoverage();
1526
return s.length() - n - 1;
1627
}
28+
public void printCoverage() {
29+
for (Map.Entry<String, Boolean> entry : branchCoverage.entrySet()) {
30+
System.out.println(entry.getKey() + " was " + (entry.getValue() ? "hit" : "not hit"));
31+
}
32+
}
1733
}
18-
1934
}

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