Skip to content

Commit 6cc4979

Browse files
authored
Create 3813. Vowel-Consonant Score.java
1 parent 7d8efee commit 6cc4979

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// 97 ~ 122
2+
// o(n)
3+
4+
class Solution {
5+
public int vowelConsonantScore(String s) {
6+
Set<Character> vowels = new HashSet<>(List.of('a', 'e', 'i', 'o', 'u'));
7+
8+
int v = 0;
9+
int c = 0;
10+
for (char letter : s.toCharArray()) {
11+
int askii = (int) letter;
12+
if (askii < 97 || askii > 122) continue;
13+
14+
if (vowels.contains(letter)) v++;
15+
else c++;
16+
}
17+
if (c==0) return 0;
18+
return v / c;
19+
}
20+
}

0 commit comments

Comments
 (0)