Skip to content

Commit 00115e4

Browse files
refactor 1358
1 parent 23c90e8 commit 00115e4

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,11 @@
11
package com.fishercoder.solutions;
22

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-
* */
273
public class _1358 {
284
public static class Solution1 {
29-
/**A classic sliding window problem, no dp or backtracking, just sliding window: use two pointers.
5+
/**
6+
* A classic sliding window problem, no dp or backtracking, just sliding window: use two pointers.
307
* my new favorite queustion!
31-
* */
8+
*/
329
public int numberOfSubstrings(String s) {
3310
int[] counts = new int[3];
3411
int i = 0;

0 commit comments

Comments
 (0)