Skip to content

Commit 662ec2f

Browse files
add 1876
1 parent 01d6a93 commit 662ec2f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1876|[Substrings of Size Three with Distinct Characters](https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1876.java) ||Easy|String|
1112
|1869|[Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1869.java) ||Easy|Array, Two Pointers|
1213
|1863|[Sum of All Subset XOR Totals](https://leetcode.com/problems/sum-of-all-subset-xor-totals/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1863.java) ||Easy|Backtracking, Recursion|
1314
|1862|[Sum of Floored Pairs](https://leetcode.com/problems/sum-of-floored-pairs/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1862.java) ||Hard|Math|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1876 {
4+
public static class Solution1 {
5+
public int countGoodSubstrings(String s) {
6+
int count = 0;
7+
for (int i = 0; i < s.length() - 2; i++) {
8+
String candidate = s.substring(i, i + 3);
9+
if (candidate.charAt(0) != candidate.charAt(1) && candidate.charAt(0) != candidate.charAt(2) && candidate.charAt(1) != candidate.charAt(2)) {
10+
count++;
11+
}
12+
}
13+
return count;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)