Algorithm Problem/Python

[python] SWEA - 10912. μ™Έλ‘œμš΄ 문자

deo2kim 2020. 11. 2. 08:15
λ°˜μ‘ν˜•

πŸ€”λ¬Έμ œ ν•΄κ²°

  • lv3 | λ¬Έμžμ—΄

πŸ’¨ λΆ™μ–΄μžˆλŠ” 문자끼리 μ‚­μ œν•˜λŠ” 것이 μ•„λ‹ˆλΌ, 어디에 있던 두 문자λ₯Ό μ°μ§€μœΌλ©΄ λœλ‹€.

πŸ’»μ†ŒμŠ€ μ½”λ“œ

for tc in range(int(input())):
    word = list(input())
    word.sort()
    stack = []

    for w in word:
        if stack and stack[-1] == w:
            stack.pop()
        else:
            stack.append(w)

    if stack:
        print(f'#{tc + 1} {"".join(stack)}')
    else:
        print(f'#{tc + 1} Good')
 

πŸ“•λ¬Έμ œ 확인

좜처: SW Expert Academy

 

SW Expert Academy

SW ν”„λ‘œκ·Έλž˜λ° μ—­λŸ‰ 강화에 도움이 λ˜λŠ” λ‹€μ–‘ν•œ ν•™μŠ΅ 컨텐츠λ₯Ό ν™•μΈν•˜μ„Έμš”!

swexpertacademy.com

 

λ°˜μ‘ν˜•