Skip to content

Commit 03050c0

Browse files
Merge pull request #1715 from CodingTestStudy2/최원준
[최원준] Day30
2 parents e6101a9 + a97ec8e commit 03050c0

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
-
6+
7+
2. 시간복잡도 :
8+
O(n)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
15+
class Solution:
16+
def reverseByType(self, s: str) -> str:
17+
# 0 char, 1 special
18+
chars = ""
19+
specials = ""
20+
21+
for c in s:
22+
if c.isalpha():
23+
chars += c
24+
else:
25+
specials += c
26+
chars = chars[::-1]
27+
specials = specials[::-1]
28+
29+
ans = ""
30+
char_idx = 0
31+
special_idx = 0
32+
33+
for c in s:
34+
if c.isalpha():
35+
ans += chars[char_idx]
36+
char_idx += 1
37+
else:
38+
ans += specials[special_idx]
39+
special_idx += 1
40+
return ans

0 commit comments

Comments
 (0)