티스토리 뷰

programmers.co.kr/learn/courses/30/lessons/64065

 

코딩테스트 연습 - 튜플

"{{2},{2,1},{2,1,3},{2,1,3,4}}" [2, 1, 3, 4] "{{1,2,3},{2,1},{1,2,4,3},{2}}" [2, 1, 3, 4] "{{4,2,3},{3},{2,3,4,1},{2,3}}" [3, 2, 4, 1]

programmers.co.kr

def solution(s):
    answer = []
    s = s[2:-2]
    s = s.split('},{')
    s = sorted(s,key = lambda x: len(x))
    
    for num in s:
        num = num.split(',')
        for n in num:
            if int(n) not in answer:
                answer.append(int(n))
            
    return answer
   
공지사항
최근에 올라온 글
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함