1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
def superReducedString(s):
# Write your code here
my_stack=[]
for i in s:
if len(my_stack) == 0 or my_stack[-1]!=i:
my_stack.append(i)
elif my_stack[-1]==i:
my_stack.pop()
answer = ''.join(my_stack)
if answer == '':
answer = 'Empty String'
return answer
if __name__ == '__ma
|
cs |
https://www.hackerrank.com/challenges/reduced-string/problem
https://sunchol21.tistory.com/1264
이 문제랑 같죠
Same problem on the link
반응형
'python-algorithm' 카테고리의 다른 글
백준 10816 숫자 카드 2 (0) | 2022.11.08 |
---|---|
백준 11866 요세푸스 문제 0 (0) | 2022.11.08 |
백준 18511 큰 수 구성하기 (0) | 2022.11.08 |
백준 1331 나이트 투어 (0) | 2022.11.08 |
백준 14582 오늘도 졌다 (0) | 2022.11.08 |
댓글