Skip to content

Commit 6bc595b

Browse files
committed
이진희
1 parent 5969544 commit 6bc595b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
3+
1. 아이디어 : 문자열 자음 모음 개수 세서 나눠주기, 이때 자음이 0이면 계산이 안되므로 0 반환
4+
5+
2. 시간복잡도 : O(N)
6+
7+
3. 자료구조/알고리즘 : 계산
8+
9+
*/
10+
11+
class Solution {
12+
public int vowelConsonantScore(String s) {
13+
int v = 0;
14+
int k = 0;
15+
16+
for(int i=0; i<s.length(); i++) {
17+
char c = s.charAt(i);
18+
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') v++;
19+
else if(c>='a' && c<='z') k++;
20+
}
21+
22+
if(k == 0) return 0;
23+
return (int)Math.floor(v/k);
24+
}
25+
}

0 commit comments

Comments
 (0)