Skip to content

Commit 8979d2e

Browse files
committed
3813
1 parent 001c781 commit 8979d2e

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'''
2+
1. 아이디어 :
3+
vowels와 consonants를 각각 count하고, v/c를 return. c가 0이면 0 return.
4+
5+
2. 시간복잡도 :
6+
o(n * 26) = o(n)
7+
8+
3. 자료구조/알고리즘 :
9+
'''
10+
from math import floor
11+
class Solution:
12+
def vowelConsonantScore(self, s: str) -> int:
13+
vowels = 'aeiou'
14+
consonants = 'bcdfghjklmnpqrstvwxyz'
15+
16+
v = 0
17+
c = 0
18+
19+
for i in s:
20+
if i in vowels:
21+
v += 1
22+
elif i in consonants:
23+
c += 1
24+
25+
try:
26+
return floor(v/c)
27+
except:
28+
return 0

0 commit comments

Comments
 (0)