본문 바로가기
파이썬 코딩테스트/해커랭크

HackerRank / String Construction / Python

by S.T.Lee 2021. 12. 27.

https://www.hackerrank.com/challenges/string-construction/problem?isFullScreen=true

 

String Construction | HackerRank

Find the minimum cost of copying string s.

www.hackerrank.com

1. 한 글자당 프린트 가격은 1원이다.

2. 이미 프린트 된 글자는 가격 소모 없이 재입력 가능하다.

 

def stringConstruction(s):
    spel_list = []
    for spel in s:
        if spel not in spel_list: #리스트에 없으면 추가
            spel_list.append(spel)
        else:
            pass
    return len(spel_list) #글자당 1원임으로