Skip to content

Commit 29fd855

Browse files
committed
Fixed sonar, added test
1 parent cdc29ba commit 29fd855

File tree

2 files changed

+6
-1
lines changed
  • src
    • main/java/g3401_3500/s3448_count_substrings_divisible_by_last_digit
    • test/java/g3401_3500/s3448_count_substrings_divisible_by_last_digit

2 files changed

+6
-1
lines changed

src/main/java/g3401_3500/s3448_count_substrings_divisible_by_last_digit/Solution.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private long countDivisibilityBy8(String s, int j) {
9797
}
9898
int num3 = (s.charAt(j - 2) - '0') * 100 + (s.charAt(j - 1) - '0') * 10 + 8;
9999
int num2 = (s.charAt(j - 1) - '0') * 10 + 8;
100-
return (num3 % 8 == 0 ? j - 1 : 0) + (num2 % 8 == 0 ? 1 : 0) + 1;
100+
return (num3 % 8 == 0 ? j - 1 : 0) + (num2 % 8 == 0 ? 1 : 0) + 1L;
101101
}
102102

103103
private long countDivisibilityBy7(int j, int[] p7, long[][] freq7, int[] inv7) {

src/test/java/g3401_3500/s3448_count_substrings_divisible_by_last_digit/SolutionTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ void countSubstrings2() {
2020
void countSubstrings3() {
2121
assertThat(new Solution().countSubstrings("1010101010"), equalTo(25L));
2222
}
23+
24+
@Test
25+
void countSubstrings4() {
26+
assertThat(new Solution().countSubstrings("4"), equalTo(1L));
27+
}
2328
}

0 commit comments

Comments
 (0)