세용용용용 2023. 7. 7. 21:14

def solution(s):
    answer = []
    s = s.split('},{')
    s[0] = s[0].replace('{','')
    s[-1] = s[-1].replace('}','')
    #print(s)
    s.sort(key=len)
    for i in s:
        i = i.split(',')
        for j in i:
            if int(j) not in answer:
                answer.append(int(j))
    #print(answer)

    return answer
solution("{{2},{2,1},{2,1,3},{2,1,3,4}}")