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

Commit4aa6fb7

Browse files
add 2315
1 parent918a63b commit4aa6fb7

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-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+
| 2315|[Count Asterisks](https://leetcode.com/problems/count-asterisks/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2315.java)|| Easy||
1112
| 2309|[Greatest English Letter in Upper and Lower Case](https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2309.java)|| Easy||
1213
| 2303|[Calculate Amount Paid in Taxes](https://leetcode.com/problems/calculate-amount-paid-in-taxes/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2303.java)|| Easy||
1314
| 2299|[Strong Password Checker II](https://leetcode.com/problems/strong-password-checker-ii/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2299.java)|| Easy||
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_2315 {
4+
publicstaticclassSolution1 {
5+
publicintcountAsterisks(Strings) {
6+
intans =0;
7+
for (inti =0;i <s.length();i++) {
8+
if (s.charAt(i) =='|') {
9+
i++;
10+
while (i <s.length() &&s.charAt(i) !='|') {
11+
i++;
12+
}
13+
}elseif (s.charAt(i) =='*') {
14+
ans++;
15+
}
16+
}
17+
returnans;
18+
}
19+
}
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.solutions._2315;
4+
importorg.junit.BeforeClass;
5+
importorg.junit.Test;
6+
7+
importstaticorg.junit.Assert.assertEquals;
8+
9+
publicclass_2315Test {
10+
privatestatic_2315.Solution1solution1;
11+
privatestaticStrings;
12+
13+
@BeforeClass
14+
publicstaticvoidsetup() {
15+
solution1 =new_2315.Solution1();
16+
}
17+
18+
@Test
19+
publicvoidtest1() {
20+
s ="l|*e*et|c**o|*de|";
21+
assertEquals(2,solution1.countAsterisks(s));
22+
}
23+
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp