관리 메뉴

솜씨좋은장씨

[BaekJoon] 5357번 : Dedupe (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 5357번 : Dedupe (Python)

솜씨좋은장씨 2022. 12. 26. 17:45
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 Dedupe 입니다.

 

5357번: Dedupe

Redundancy in this world is pointless. Let’s get rid of all redundancy. For example AAABB is redundant. Why not just use AB? Given a string, remove all consecutive letters that are the same.

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def dedupe(dup_string):
    dedupe_string = [dup_string[0]]
    
    for word in dup_string[1:]:
        if word != dedupe_string[-1]:
            dedupe_string.append(word)
            
    return "".join(dedupe_string)


if __name__ =="__main__":
    for _ in range(int(input())):
        dup_string = input()
        
        print(dedupe(dup_string=dup_string))
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments