𝘼𝙣𝙖𝙡𝙮𝙨𝙞𝙨/ᴀʟɢᴏʀɪᴛʜᴍ

dict.fromkeys() : 순서는 유지한 채 중복값들을 제거

콜라맛갈비 2023. 6. 23. 16:16
728x90

 

 

순서는 유지한 채 중복값들을 제거

dict.fromkeys()

 

https://school.programmers.co.kr/learn/courses/30/lessons/120852

def solution(n):
    answer = []
    
    i = 2
    while i <= n :
        if n % i == 0 :
            answer.append(i)
            n = n // i
        else :
            i += 1
    
    return list(dict.fromkeys(answer))
728x90