Skip to content

Commit 8b60021

Browse files
authored
Create Percentage of Letter in String.java
1 parent 2536581 commit 8b60021

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int percentageLetter(String s, char letter) {
3+
int letterCount = 0;
4+
for (char c : s.toCharArray()) {
5+
if (c == letter) {
6+
letterCount++;
7+
}
8+
}
9+
return (letterCount * 100) / s.length();
10+
}
11+
}

0 commit comments

Comments
 (0)