Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit00115e4

Browse files
refactor 1358
1 parent23c90e8 commit00115e4

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
packagecom.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
publicclass_1358 {
284
publicstaticclassSolution1 {
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
publicintnumberOfSubstrings(Strings) {
3310
int[]counts =newint[3];
3411
inti =0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp