Skip to content

Commit cfbad80

Browse files
add 3120
1 parent 9b9e519 commit cfbad80

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ _If you like this project, please leave me a star._ ★
99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|----------------------------------------------------------------------
1111
| 3131 |[Find the Integer Added to Array I](https://leetcode.com/problems/find-the-integer-added-to-array-i/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3131.java) | | Easy |
12-
| 3127 |[Make a Square with the Same Color](https://leetcode.com/problems/make-a-square-with-the-same-color/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3127.java) | | Easy |
12+
| 3127 |[Make a Square with the Same Color](https://leetcode.com/problems/make-a-square-with-the-same-color/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3127.java) | | Easy |
13+
| 3120 |[Count the Number of Special Characters I](https://leetcode.com/problems/count-the-number-of-special-characters-i/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3120.java) | | Easy |
1314
| 3046 |[Split the Array](https://leetcode.com/problems/split-the-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3046.java) | | Easy |
1415
| 3042 |[Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3042.java) | | Easy |
1516
| 3038 |[Maximum Number of Operations With the Same Score I](https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/)| [Java](../master/src/main/java/com/fishercoder/solutions/_3038.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _3120 {
4+
public static class Solution1 {
5+
public int numberOfSpecialChars(String word) {
6+
int count = 0;
7+
int[] lower = new int[26];
8+
int[] upper = new int[26];
9+
for (char c : word.toCharArray()) {
10+
if (Character.isLowerCase(c)) {
11+
lower[c - 'a']++;
12+
} else {
13+
upper[c - 'A']++;
14+
}
15+
}
16+
for (int i = 0; i < 26; i++) {
17+
if (lower[i] != 0 && upper[i] != 0) {
18+
count++;
19+
}
20+
}
21+
return count;
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)