본문 바로가기
python-algorithm

Hacker rank Super Reduced String

by 무적김두칠 2022. 11. 8.
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

 

Super Reduced String | HackerRank

Given a string, repeatedly remove adjacent pairs of matching characters and then print the reduced result.

www.hackerrank.com

https://sunchol21.tistory.com/1264

 

프로그래머스 짝지어 제거하기

https://school.programmers.co.kr/learn/courses/30/lessons/12973 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는

sunchol21.tistory.com

이 문제랑 같죠
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

댓글