Skip to content

Commit 56cffba

Browse files
add 1358
1 parent 58abb75 commit 56cffba

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
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+
|1358|[Number of Substrings Containing All Three Characters](https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1358.java) | |Medium|String|
1112
|1357|[Apply Discount Every n Orders](https://leetcode.com/problems/apply-discount-every-n-orders/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1357.java) | |Medium|Design|
1213
|1356|[Sort Integers by The Number of 1 Bits](https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1356.java) | |Easy|Sort, Bit Manipulation|
1314
|1354|[Construct Target Array With Multiple Sums](https://leetcode.com/problems/construct-target-array-with-multiple-sums/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1354.java) | |Hard|Greedy|
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fishercoder.solutions;
2+
3+
/**
4+
* 1358. Number of Substrings Containing All Three Characters
5+
*
6+
* Given a string s consisting only of characters a, b and c.
7+
* Return the number of substrings containing at least one occurrence of all these characters a, b and c.
8+
*
9+
* Example 1:
10+
* Input: s = "abcabc"
11+
* Output: 10
12+
* Explanation: The substrings containing at least one occurrence of the characters a, b and c are "abc", "abca", "abcab", "abcabc", "bca", "bcab", "bcabc", "cab", "cabc" and "abc" (again).
13+
*
14+
* Example 2:
15+
* Input: s = "aaacb"
16+
* Output: 3
17+
* Explanation: The substrings containing at least one occurrence of the characters a, b and c are "aaacb", "aacb" and "acb".
18+
*
19+
* Example 3:
20+
* Input: s = "abc"
21+
* Output: 1
22+
*
23+
* Constraints:
24+
* 3 <= s.length <= 5 x 10^4
25+
* s only consists of a, b or c characters.
26+
* */
27+
public class _1358 {
28+
public static class Solution1 {
29+
public int numberOfSubstrings(String s) {
30+
//TODO: implement it
31+
return -1;
32+
}
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.solutions._1358;
4+
import org.junit.BeforeClass;
5+
import org.junit.Ignore;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.assertEquals;
9+
10+
@Ignore
11+
public class _1358Test {
12+
private static _1358.Solution1 solution1;
13+
14+
@BeforeClass
15+
public static void setup() {
16+
solution1 = new _1358.Solution1();
17+
}
18+
19+
@Test
20+
public void test1() {
21+
assertEquals(10, solution1.numberOfSubstrings("abcabc"));
22+
}
23+
24+
@Test
25+
public void test2() {
26+
assertEquals(3, solution1.numberOfSubstrings("aaacb"));
27+
}
28+
29+
@Test
30+
public void test3() {
31+
assertEquals(1, solution1.numberOfSubstrings("abc"));
32+
}
33+
34+
}

0 commit comments

Comments
 (0)