Skip to content

Commit a6f0f69

Browse files
committed
optimise daily
1 parent 4cc4193 commit a6f0f69

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def sortVowels(self, s: str) -> str:
3+
b = 'AEIOUaeiou'
4+
base = {x: i for i, x in enumerate(b)}
5+
cnt = [0] * len(base)
6+
7+
for c in s :
8+
if c in base :
9+
cnt[base[c]] += 1
10+
11+
output = []
12+
i = 0
13+
14+
for c in s :
15+
if c not in base :
16+
output.append(c)
17+
continue
18+
while i < len(cnt) and cnt[i] == 0 :
19+
i += 1
20+
output.append(b[i])
21+
cnt[i] -= 1
22+
23+
return ''.join(output)

0 commit comments

Comments
 (0)