Skip to content

Commit 4aa6fb7

Browse files
add 2315
1 parent 918a63b commit 4aa6fb7

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+
package com.fishercoder.solutions;
2+
3+
public class _2315 {
4+
public static class Solution1 {
5+
public int countAsterisks(String s) {
6+
int ans = 0;
7+
for (int i = 0; i < s.length(); i++) {
8+
if (s.charAt(i) == '|') {
9+
i++;
10+
while (i < s.length() && s.charAt(i) != '|') {
11+
i++;
12+
}
13+
} else if (s.charAt(i) == '*') {
14+
ans++;
15+
}
16+
}
17+
return ans;
18+
}
19+
}
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.solutions._2315;
4+
import org.junit.BeforeClass;
5+
import org.junit.Test;
6+
7+
import static org.junit.Assert.assertEquals;
8+
9+
public class _2315Test {
10+
private static _2315.Solution1 solution1;
11+
private static String s;
12+
13+
@BeforeClass
14+
public static void setup() {
15+
solution1 = new _2315.Solution1();
16+
}
17+
18+
@Test
19+
public void test1() {
20+
s = "l|*e*et|c**o|*de|";
21+
assertEquals(2, solution1.countAsterisks(s));
22+
}
23+
24+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy